Commit Graph

13877 Commits

Author SHA1 Message Date
Kyriakos Z
a0c5d8feab MM-36234,MM-37030,MM-37031: CRT, desktop thread notifications (#18088)
* CRT: desktop thread notifications

* Fixes go lint

* Adds default for desktop CRT notifications

* Adds email and push notifications for CRT threads

Adds user ids of thread followers with CRT to crtMentions so they will get
notified appropriately.

* Minor change

* Refactor a bit

CRTMentions.addMention had a bug on the return and de-duplication.
This commit fixes duplicate notifications by looking up if the user is to be
notified on CRT on both email and push notifications.

* Minor refactor

* Changes according to review comments

- Fixes adding to followers a user that had explicitly unfollowed a
  thread.
- Simplified send email according to email_threads option
- Send mentions and followers in separate arrays via the websocket
- Fixes push notifications message for push_threads

* Adds a comment on a buggy use case

* Updates comment to correct ticket link

* Fixes when user notifications is set to all

There was a bug where if user had set notifications to all
then they would receive desktop notifications even for non following threads.

A similar bug existed in push notifications, where if a user has set it
to all the threads setting would still be considered.

This commit fixes that by adding users to notificationsForCRT
StringArray when they have the non thread setting to 'all'.

* Fixes notifications to users unfollowing threads

Users which had previously explicitly unfollowed a thread
should not receive notifications about those threads.

* Update store mocks

* Fixes push notifications for CRT

Push notification about replies for CRT users should have a title of
"Reply to Thread".

CRT users with global user setting to 'UserNotifyAll' should not get
notifications for unfollowed threads.

This commit fixes those issues.

* Fixes i18n error

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-19 17:28:46 +03:00
Devin Binnie
fbbd1193dc [MM-37682] Expose SiteURL to non-authenticated sessions (#18146)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-19 10:05:30 -04:00
Claudio Costa
80fa8a4d62 Bring back jobserver command (#18220) 2021-08-19 11:06:27 +02:00
Ben Schumacher
e0f51f54e1 [MM-23279] Idiomatic naming (IP) (#18152) 2021-08-19 10:33:29 +02:00
Martin Kraft
8f01a1b5a1 MM-36448: Removes legacy CLI commands. (#17995)
* MM-36448: Removes legacy CLI commands.

* MM-26448: Update translations.

* MM-36448: Fixes some lint errors.

* MM-36448: Conflict resolution error fix. Lint fixes.

* MM-36448: Removes some more commands.

* MM-36448: Removes unused functions.

* MM-36448: Re-adds config command.

* MM-36448: Re-adds func for use by config.

* MM-36448: Moved structs back.

* MM-36488: Re-adds version.

* MM-36448: Re-added some commands.

* MM-36448: Fix tests.

* MM-36448: Removed unused func.

* MM-36448: Removes test.

* MM-36448: Removes uses of 'config set'.

* MM-36448: Moves some test structs.

* MM-36448: Removes the logs command.

* MM-36448: Re-deleted file after bad merge.

* MM-36448: Deleted test files again.

* MM-36448: Re-delete files.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-18 14:06:28 -04:00
Doug Lauder
2560469bc7 MM-38016 Fix racy unit test (TestService_AddTopicListener) (#18207)
* remove CreateTestLogger API 
* add missing mockServer.Shutdown
2021-08-18 13:44:04 -04:00
Allan Guwatudde
117cfae0bf [MM-37726] - Self-managed: Update email template to new branding - Invitation email (#18200)
* [MM-37726] -  Self-managed: Update email template to new branding - Invitation email

* fix subtitle color

* fix other template subtitle colors

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-18 20:09:37 +03:00
Ben Cooke
ce081357e8 [MM-36445] Changing elastic search docker version (#18117)
* changing elastic docker version for testing

* fixing elastic issue

* temp dockerfile

* test

* removing command

* fixing dockerfile

* adding 7.0.0

* using elasticsearch 7

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
2021-08-18 11:26:05 -04:00
Claudio Costa
536895a9ba Bump max allowed file uploads per post (#17948) 2021-08-18 15:50:17 +02:00
Devin Binnie
0dbaa48741 Change inbucket default port from 10080 to 9001 (#18145) 2021-08-18 09:31:25 -04:00
Allan Guwatudde
2547e47eab [MM-37727] - Self-managed: Update email template to new branding - Mention (#18134)
* [MM-37727] - Self-managed: Update email template to new branding - Mention

* fix lint

* truncate long channel names

* change rgba to rgb

* feedback impl

* adjust character truncation length

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-18 16:14:47 +03:00
Christopher Poile
098099aedd prepackage v1.16.1 (#18155) 2021-08-18 08:59:57 -04:00
Doug Lauder
328d96b76b MM-38004 fix racy unit test (#18189)
* fix racy unit test
* check for nil err
* fix stringer and namederr as well
2021-08-18 08:42:48 -04:00
Claudio Costa
fe9407d801 Fix bad merge (#18201) 2021-08-18 12:28:57 +02:00
Aleksandr Ulianov
dfc70ba716 fix: replace zz+model.NewId with NewTestId (#18197)
Automatic Merge
2021-08-18 12:15:04 +02:00
chitramdasgupta
199a9a71ef Replaced all instances of "zz" + model.NewId() with NewTestId()(#18194) (#18196)
Automatic Merge
2021-08-18 11:45:03 +02:00
Claudio Costa
85fd80d3f4 [MM-37846] Fix payload for post deleted event (#18131)
* Fix payload for post deleted event

* Add test
2021-08-18 10:39:25 +02:00
Doug Lauder
a4507327a7 MM-36764 mlog refactor (#18118)
Refactor mlog
- simplify mlog by removing redundant code
- remove Zap dependency
- update unit test helpers
- update logging config
- update auditing
2021-08-17 16:08:04 -04:00
Claudio Costa
04b27ce93c [MM-28985] Remove pointers to slice (part 1) (#18034)
* Remove pointers to slice (part 1)

* Remove use of pointers to slice from model package (#18045)

* Fix after merge
2021-08-17 11:18:33 +02:00
Agniva De Sarker
132f114793 Modified updateUserNotifyProps to directly update the field (#18097)
* Modified updateUserNotifyProps to directly update the field

The method was only being used during import and it unnecessarily
made multiple queries to the DB.

Changed to a separate query that just updated the props field.

https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=e4f9a891-85d6-4886-8590-1e327f7f8b8f

```release-note
NONE
```

* invalidating cache

```release-note
NONE
```
2021-08-17 10:51:41 +02:00
Claudio Costa
d181ae9262 [MM-29217] Remove Posts.ParentId (#17923) 2021-08-17 11:25:22 +03:00
Ben Schumacher
757dc96461 [MM-37772] Idiomatic naming (URL, URI, API) (#18128)
* s/Url/URL/g & s/Uri/URI/g

* s/Api/API/g
2021-08-16 19:46:44 +02:00
Ben Cooke
a7f5512ff3 [MM-18391] Removing convert channel endpoint (#18015)
* removing convert endpoint

* fixing translations

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
2021-08-16 09:10:31 -07:00
Allan Guwatudde
f43aa7d925 [MM-37726] - Self-managed: Update email template to new branding - Invitation email (#18136)
* [MM-37726] - Self-managed: Update email template to new branding - Invitation email

* build

* feedback impl

* feedback impl

* feedback impl

* fix template

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-16 19:01:32 +03:00
Agniva De Sarker
dd67fea99b Use DB native JSON operations for Delete post (#18122)
* Use DB native JSON operations for Delete post

https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=cb23f737-89c3-4e19-861e-2466c0a16205

```release-note
NONE
```

* move to adapters

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-16 20:35:19 +05:30
Martin Kraft
4db27ceda9 Switch to mysql/mysql-server docker image for ARM64 support. (#18137) 2021-08-16 09:23:21 -04:00
Weblate (bot)
d0629503e8 Translations update from Weblate (#18143)
* Translated using Weblate (German)

Currently translated at 100.0% (2309 of 2309 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/

* Translated using Weblate (Turkish)

Currently translated at 100.0% (2309 of 2309 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/

* Translated using Weblate (Hungarian)

Currently translated at 100.0% (2309 of 2309 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

* Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

* Translated using Weblate (German)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/

* Translated using Weblate (Turkish)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/

* Translated using Weblate (Hungarian)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

* Translated using Weblate (English (Australia))

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/en_AU/

* Translated using Weblate (Bulgarian)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/bg/

* Translated using Weblate (Japanese)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/ja/

* Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/zh_Hans/

Co-authored-by: JtheBAB <srast@bioc.uzh.ch>
Co-authored-by: Kaya Zeren <kayazeren@gmail.com>
Co-authored-by: Tóth Csaba // Online ERP Hungary Kft <csaba.toth@online-erp.hu>
Co-authored-by: Matthew Williams <Matthew.Williams@outlook.com.au>
Co-authored-by: Nikolai Zahariev <nikolaiz@yahoo.com>
Co-authored-by: kaakaa <stooner.hoe@gmail.com>
Co-authored-by: aeomin <lin@aeomin.net>
2021-08-16 10:49:23 +02:00
Claudio Costa
308a88efb1 [MM-37898] Exclude bots from initial user store emptiness check (#18139)
* Exclude bots from initial user store emptiness check

* Add test
2021-08-14 07:40:16 +02:00
Ben Schumacher
cbba2f1cca [MM-37664] Remove deprecated Backend field from plugin manifest (#18064) 2021-08-13 19:41:32 +02:00
Agniva De Sarker
d447d9b64a Skip flaky TestTrialLicense (#18125)
https://mattermost.atlassian.net/browse/MM-36695

```release-note
NONE
```
2021-08-13 20:39:40 +05:30
Agniva De Sarker
d1b164ab1f Improve session cleanup (#18123)
- We move logging statements to the upper layer.
Store functions are low-level methods and should return error
upwards rather than logging.
- Used IN instead of any (array ()) which is equivalent.
- Made the delay to be of type time.Duration and un-exported it.
- Unexported the batch size constant.

```release-note
NONE
```
2021-08-13 20:15:24 +05:30
Agniva De Sarker
2711262729 Update Session Props to use one query (#18120)
https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=6f15ea48-995c-4975-8b28-bd58f7d6a34a

```release-note
NONE
```
2021-08-13 20:13:27 +05:30
Agniva De Sarker
db80740414 MM-37378: Unskip TestPanicLog (#18119)
Config watcher has been removed from codebase.
It is safe to bring this back now.

https://mattermost.atlassian.net/browse/MM-37378

```release-note
NONE
```
2021-08-13 20:13:01 +05:30
Maria A Nunez
d5e61e8093 MM-36084 - Certificate Auth: Remove SAML dependency in license check (#18113) 2021-08-13 09:57:26 -04:00
Ben Schumacher
16d8640072 [MM-37760] Reduce export surface of client4 (#18102) 2021-08-13 14:02:07 +02:00
Ben Schumacher
a8ca5c423f [MM-37557] Move error out of client4 response (#18101)
* Return an error seperately from Response

* Remove BuildErrorResponse

* Drop Response.Error from model/client4.go

* Migrate require.Nil checks

* Migrate require.NotNil checks

* More manual fixes

* Move error check out of CheckOKStatus and CheckCreatedStatus

* Move error check out of CheckForbiddenStatus

* Move error check out of CheckUnauthorizedStatus

* Move error check out of CheckNotFoundStatus

* Move error check out of CheckBadRequestStatus

* Move error check out of CheckNotImplementedStatus and CheckRequestEntityTooLargeStatus

* Move error check out of CheckInternalErrorStatus

* Move error check out of CheckServiceUnavailableStatus

* Remove error check from checkHTTPStatus

* Remove remaining references to Response.Error

* Check previously unchecked errors

* Manually fix compile and linter errors

* Return error in CreateWebSocket methods

* Return error instead of *AppError in DoApi methods

* Manually fix bad replacments

* Conistently return Response and error

* Use err instead of seperate bool return value to indicate success

* Reduce ussage of model.AppError in web/oauth_test.go

* Remove client4.Must

* Check error in buf.ReadFrom

* Fix failing tests
2021-08-13 13:12:16 +02:00
Claudio Costa
96593580ae Add MaxImageResolution config setting (#17941) 2021-08-12 17:43:10 +02:00
Agniva De Sarker
e1b0644b0d Using native JSON operations to add thread participants (#18093)
Automatic Merge
2021-08-12 16:45:03 +02:00
Ben Schumacher
fd853e74a6 [MM-37755] Idiomatic naming (SMTP, TLS, TCP, XML, CSS, HTML, HTTP) (#18103) 2021-08-12 11:49:16 +02:00
Claudio Costa
bd65e8daf9 Replace db count query in user signup process (#18072) 2021-08-12 11:23:21 +02:00
Allan Guwatudde
d3973557fc [MM-37616] Self-managed: Update email template to new branding - Welcome and Verification email (#18076)
* [MM-37616] - Update Welcome and Verify emails to new branding

* make build-templates

* styling feedback
2021-08-12 11:55:16 +03:00
Ben Schumacher
225565f412 [MM-37716] Drop support for LHS specific bot icons (#18087) 2021-08-12 00:27:35 +02:00
Agniva De Sarker
99bb6084b3 Remove remnants of config watcher (#18067)
The last part of config watching was in advanced logging.
We remove it from there too to keep things consistent.

https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=a1b58527-6a3d-4faa-8144-166a3698731f

```release-note
Removed config watch feature from advanced logging config.
```
2021-08-12 01:15:02 +05:30
Claudio Costa
868b8d91db [MM-36318] Set bot profile image and icon only if they have changed (#18008)
* Set bot profile image and icon only if they have changed

* Move equality check to the app layer

* Use ioutil.ReadAll

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-11 09:37:52 +02:00
Carlos Tadeu Panato Junior
2982cc6f4e update mm server builder to use go 1.16.7 (#18107) 2021-08-10 18:53:35 +02:00
Agniva De Sarker
555656d0f9 Skip TestPreparePostForClient (#18100)
https://mattermost.atlassian.net/browse/MM-37757

```release-note
NONE
```
2021-08-10 19:55:32 +05:30
Weblate (bot)
48258d73b5 Translations update from Weblate (#18098)
* Translated using Weblate (Hungarian)

Currently translated at 100.0% (2305 of 2305 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 100.0% (2305 of 2305 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 100.0% (2305 of 2305 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 100.0% (2305 of 2305 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

* Translated using Weblate (Hungarian)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 99.6% (2301 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 99.6% (2300 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 99.6% (2301 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 99.6% (2301 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 99.6% (2298 of 2305 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

Translated using Weblate (Hungarian)

Currently translated at 100.0% (2305 of 2305 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

* Translated using Weblate (German)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/

* Translated using Weblate (Turkish)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/

Translated using Weblate (Turkish)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/

Translated using Weblate (Turkish)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/

* Translated using Weblate (Swedish)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/sv/

Translated using Weblate (Swedish)

Currently translated at 99.9% (2307 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/sv/

Translated using Weblate (Swedish)

Currently translated at 99.8% (2305 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/sv/

* Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/zh_Hans/

* Translated using Weblate (English (Australia))

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/en_AU/

* Translated using Weblate (Japanese)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/ja/

* Translated using Weblate (Dutch)

Currently translated at 100.0% (2308 of 2308 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/nl/

Co-authored-by: Zsolt Godó <zsolttokio@gmail.com>
Co-authored-by: Tóth Csaba // Online ERP Hungary Kft <csaba.toth@online-erp.hu>
Co-authored-by: JtheBAB <srast@bioc.uzh.ch>
Co-authored-by: Kaya Zeren <kayazeren@gmail.com>
Co-authored-by: MArtin Johnson <martinjohnson@bahnhof.se>
Co-authored-by: aeomin <lin@aeomin.net>
Co-authored-by: Matthew Williams <Matthew.Williams@outlook.com.au>
Co-authored-by: kaakaa <stooner.hoe@gmail.com>
Co-authored-by: Tom De Moor <tom@controlaltdieliet.be>
2021-08-10 12:28:03 +02:00
Claudio Costa
afc393d8e9 Fix possible endless loop (#18079)
* Fix endless loop

* Add test
2021-08-10 10:12:43 +02:00
dave
16c2925ba2 Fix staticcheck errors from _test.go files (#18033)
Automatic Merge
2021-08-10 07:15:03 +02:00
Agniva De Sarker
3f01129ddf MM-37165: Fix improper plugin shutdown (#18044)
* MM-37165: Fix improper plugin shutdown

This was caught from a race test failure. While the failure manifested due to a log being
written from a test after the test exited, the real reason was hidden further deeper.

What was happening is that the server would always listen for plugin requests in a
separate goroutine via `g.muxBroker.AcceptAndServe` in the `OnActivate` hook. But the
plugin shutdown process would just close the plugin connections and move on, leading
to the classic case of improperly shut down goroutines.

When this happened, an opportunity opens up in a way that the server
would still be executing a request whereas the main goroutine and therefore the parent
test has already finished. This would lead to an error like

```
{"level":"error","ts":1626451258.4141135,"caller":"mlog/sugar.go:25","msg":"pluginAPI scheduleOnce poller encountered an error but is still polling","plugin_id":"com.mattermost.plugin-incident-management","error":"ListPluginKeys: Unable to list all the plugin keys., failed to get PluginKeyValues with pluginId=com.mattermost.plugin-incident-management: sql: database is closed
```

And now, this finally calls `mlog.Error`, which finally triggers our race condition :)

To fix this, we use some basic synchronization via waitgroups and just wait for it
to finish after closing the plugin process.

https://mattermost.atlassian.net/browse/MM-37165

```release-note
NONE
```

* gofmt

```release-note
NONE
```

* split waitgroup additions

```release-note
NONE
```
2021-08-10 10:07:35 +05:30