Граф коммитов

2847 Коммитов

Автор SHA1 Сообщение Дата
Joram Wilander
f33fba1d4f Add new /test dms command (#19565)
* Add new /test dms command

* Remove useless team get
2022-02-17 17:48:51 -05:00
mkraft
7fa6b321ae Custom groups (#18839)
* WIP

* adding initial creategroup endpoint

* fetching by group source

* fixing startup error

* updating create endpoint to take an array of user_ids, this will allow us to create the group with one request

* adding delete group endpoint and appropriate test

* adding source param for getGroups

* adding add members and delete members endpoints

* locking down crud endpoints to only be allowed for custom groups

* user search stuff

* allowing remoteid be null by changing field to pointer

* code cleanup and store level tests

* adding new tests and removing unused endpoint

* resolving conflicts

* Adds authz check for group.

* Adds authz checks to groups APIs.

* Updated create group authz tests.

* Updates delete group tests.

* Tests create group.

* Adds some tests and validations.

* adding new parameter so I can get users not in a group

* Fixed all lint warnings.

* Fix type.

* fixing search users not in group

* Fixes some lint errors.

* Moves entry in JSON array.

* Fixed SQL query.

* Fixes permission migration test.

* Fixes migration test.

* Fixes some group store tests.

* Fix test.

* Fix test.

* Revert lint change.

* Migrated CreateWithUserIds to sqlx.

* Adds tests for GetMember; migrates implementation to sqlx.

* Tests GetNonMemberUsersPage and hanles wrong group id.

* Fixes test.

* Switches GetMaster to GetMasterX.

* Switches GetReplica to GetReplicaX.

* Fixes logic.

* Fixes shadow declaration.

* Adds include_member_count to get group API endpoint.

* Adds filter_has_member param to getGroups.

* Fixes.

* Removes array of group sources.

* fixing error

* Testing reverting CreateWithUserIds back to gorp.

* Added websocket event for CreateGroupWithUserIds.

* Changed a few response status codes. Switched to correct permission.

* Added member count to ws payload for group when updating or creating.

* Adds feature flag checks for custom groups.

* Added middleware function to require license. Added config to disable custom groups.

* Change for function signature change of executePossiblyEmptyQuery.

* Lint fixes.

* Adds telemetry none comment.

* Adds translations.

* Migrated to sqlx.

* Temp. removal of translation.

* Fixed typo.

* Added an intermediary model to query with a field that is now ignored by sqlx on read queries.

* Re-used existing store struct.

* Inludes member count.

* Fix for merge error.'

* Require license for group endpoints.

* Updates translations.

* Fix shadow declaration.

* Renames permissions. Switches to new method to retrieve remoteid.

* Added WS events for upsert and delete member(s).

* Added new store error type ErrUniqueConstraint.

* Added EnableCustonGroups to the client config.

* Sanitized some user records.

* Added parameter to include_total_count for listing groups.

* Added translations.

* adding deleteAt field to getByUsers query

* Revert sanitize.

* Added uniqueness constraint error to UpdateGroup.

* Removed the FutureFeatures flag so that the feature is not enabled on old Enterprise licenses.

* Renamed function.

* Updates authz check for user search related to groups.

* Removed debug statement.

* Removed unused app method.

* Added telemetry for enable_custom_groups.

* Returns early from nil license.

* Updates test.

* Returned early to avoid nesting in (*SqlGroupStore).checkUserExist. Switched to reading from replica in (*SqlGroupStore).GetMember. Handled JSON marshal error in (*Client4).UpsertGroupMembers

* Switched to SanitizeProfile.

* Switched to model.NewInt.

* Switched from status NotImplemented to Forbidden for missing license.

* Removed deactivated users from 'exists' set.

* Revert gotool update.

* Ignored lint error that I think is invalid.

* Added the approprate access tag for disabling custom groups.

* Revert change to response status.

* Fixed refactor mistake.

* Limited the group member WS events to individual users.

* Removed WS event of deleted groups.

* Updated license check for searchUsers endpoint.

* Switched from license feature to license sku.

* Update app/group.go

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

* Update app/group.go

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

* Remove linter ignore comment.

* Added function to create sku-specific license.

* Fixed typo. Removed comment.

* Fixed for wrong type.

* Added missing param to client. Removed unnecessary props setting. Added test for retrieving groups by source.

* Updated some tests now that we're validating group membership not created for deactivated user.

* Fix for groups endpoint returning all group types by default.

* Changes constant names. Adds migration for all users to manage custom group members.

* Removes requirement for manage_system permission to filter user search by group.

* Added migration mock.

* Removes default permissions from custom_group_user role.

* Fixes migration.

* Fixes emoji migration test.

* fixing issue with member counts

* fixing search issue for deleted members

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.fritz.box>
Co-authored-by: Claudio Costa <cstcld91@gmail.com>
2022-02-17 12:34:39 -05:00
Agniva De Sarker
7f1d074d85 Changing log level for some license logs (#19585)
Based on observations from: https://community-daily.mattermost.com/core/pl/opdbqncpx3b9fdbkiaj17t5muy

```release-note
NONE
```
2022-02-17 22:06:10 +05:30
Nathaniel Allred
a3c1507563 Remove wait group for onboarding complete code (#19580)
* remove wait group for onboarding complete code
2022-02-17 10:05:37 -06:00
Agniva De Sarker
6898b3d70f Optimize TeamsUnread (#19507)
The GetTeamsUnreadForUser call would be called for every team switch.
In CRT mode, it would make a separate store call for every team, which
would run the 3 aggregate SQL queries in GetThreadsForUser.

This is suboptimal because the complexity is linearly proportional
to the number of teams.

We make the following optimizations:
1. Change the query to a single one which aggregates all teams.
2. The query originally used just 2 out of the 3 queries, so one
query was fully redundant. We remove that query in the new one.
3. Further analysis was done whether it makes sense to run the 2
queries synchronously or not. The load-tests didn't show any degradation
in running them concurrently, so we keep the same behavior.

```release-note
NONE
```
2022-02-17 09:24:39 +05:30
Agniva De Sarker
678c7d3b8c Replace remaining GetMaster() queries (#19545)
There are still some remaining which
access the raw DB struct. There will be
a separate PR to clean those up.

```release-note
NONE
```
2022-02-16 22:30:27 +05:30
Agniva De Sarker
256427f7f9 Change log level for missing plugin (#19573)
As discussed offline, this is not an actionable error message
and should therefore be demoted to debug.

```release-note
NONE
```
2022-02-16 22:29:27 +05:30
Nathaniel Allred
459f54ac9d Use case onboarding (#19446)
* Add use case onboarding feature flag
* Add endpoints and storage for whether first admin completed setup
* Add migration for FirstAdminSetupComplete

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2022-02-15 17:46:03 -06:00
mkraft
627dd650d6 Revert "MM-41211: Adds ability to set SessionLengthSSOInDays to a decimal. (#19396)" (#19563)
This reverts commit 7398451030.
2022-02-15 12:50:56 -05:00
Ibrahim Serdar Acikgoz
cf9ed13d24 fix typo in the app/export_test.go (#19553) 2022-02-15 09:42:13 +03:00
Jesús Espino
2c3e289509 Working on refactoring jobs service (#19205)
* Working on refactoring jobs service

* Making more consistent with the previous existing code

* Remove no longer needed functions

* Making a base PeridicScheduler to use it in most of the schedulers implementations

* Removing accidental complexity from on of the jobs

* Removing accidental complexity from expirynotify

* Fixing compilation from previous commit

* Remove accidental complexity from the export_delete job

* Simplifying the workers by making a reusable worker

* Using simple worker for export_delete job

* Simpliying export process job

* Simpliying extract content job

* Simpliying import delete job

* Simpliying import process job

* Simpliying product noticies job

* Simpliying fix crt channel unreads job (only removing the uneeded register function)

* Simpliying migrations job (only removing the uneeded register function)

* fixup

* Simpliying plugins job (only removing the uneeded register function)

* Simpliying bleve indexing job (only removing the uneeded register function)

* Simpliying resend invitation email job (only removing the uneeded register function)

* Fixing tests

* Simplifying migration tests infrastructure

* Adding missed license to files

* Adding an empty file to imports package to ensure this package exist even without enterprise repo

* Regenerating einterfaces mocks

* Adding missed license to files

* Updating i18n/en.json file

* help fixing enterprise tests compilation

* Adding new DailyScheduler

* Fixing typo and changing the waitTime type for periodic sechduler

* Making the daily scheduler more generic

* Adding comments to clarify not used parameters in interface scheduler interface implementations

* Using merror to handle multiple errors in jobs workers

* Fixing linter errors

* Addressing PR review comments

* Reverting go.tools.mod changes

* Removing the static check for worker type in the model (moving it to the insertion of new jobs

* Moving migrations job to the jobs directory

* Fixing (and improving a bit) tests

* Apply suggestions from code review

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>

* Fixing enterprise tests

* Removing unneeded InitWorkers/InitSchedulers calls

* Fix expirenotify job when error happens

* Fixing govet errors

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
2022-02-14 18:21:18 +01:00
mkraft
7398451030 MM-41211: Adds ability to set SessionLengthSSOInDays to a decimal. (#19396)
* MM-41211: Accepts a decimal for the SSO session length.

* MM-41211: Fixes test and logic error.

* MM-41211: Validates session length is minimum 1 hour.

* MM-41211: Tricking the CI to allow an empty string.

* Fixes a test error and some lint changes.

* Fix error.

* Reverting IDE change.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-02-14 12:06:47 -05:00
Agniva De Sarker
10c8c84704 MM-41796: Sentry crash: use the correct error variable (#19547)
We use the correct error variable while checking
for the error

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

```release-note
NONE
```
2022-02-14 19:49:26 +05:30
Ben Cooke
88968f9e17 Growth spike guest accounts (#19437)
* tools updates

* Revert "tools updates"

This reverts commit 6293297b55803c5a263e200ebd80192899666ae9.

* new endpoint to get users that should potentially be guests

* checking authservice to ensure they were an email signup

* adding tests for new endpoint

* fixing translation issue

* permissions for new endpoint

* fixing tests

* fixing when domain array is empty

* fixing when domain array is empty

* removing bots from request

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home>
Co-authored-by: mkraft <martinkraft@gmail.com>
2022-02-10 15:36:14 -05:00
Ben Schumacher
0d67995eb4 [MM-41200] Add OnSendDailyTelemetry() plugin hook (#19387) 2022-02-10 06:20:00 +01:00
Kyriakos Z
457aeb8e7e MM-36589: provide previous values for unreads (#18492)
* MM-36589: provide previous values for unreads

To successfully figure out the new counts of mentions or unread replies
for CRT we need to provide previous values alongside with the new.
This is needed so we'll know how many to subtract from the total.

This commit provides those numbers upon publishing websocket ThreadUpdated
and ThreadReadChanged events.

* Fixes errors

* Removes unneeded lines

* Adds GetThreadUnreadReplyCount store method

Uses the new store method to get unread replies instead of
GetThreadForUser.

* Tests, and some changes

- Adds api4 tests to test ws events
- Uses sqlx instead of gorp for new store method
- Fixes case where previous_unread_replies could be a negative value

* Refactors tests and adds more cases

* Fixes previous and current unread counts for commenter

When a user posts a reply to a thread the unread counts had a couple of
issues.
UnreadMentions where not zeroed out, and previous unread counts where
not set correctly.

This commit tries to fix that by marking the thread as read for the
current poster after we set previous unread counts to the websocket
event data.

Also MaintainMembership should zero out UnreadMentions when we are
setting the thread as read.

* Oops

* Fixes tests by updating when maintaining membership

OK, so some tests broke because we zero UnreadMentions in the membership
when we UpdateViewedTimestamp, since the new timestamp is always now.

Some tests broke because MaintainMembership for the commenter so that
the thread is read each time commenter posts moved further down in the
SendNotification method.

BOTH those test cases are fixed with this commit. To be sincere though I
don't understand why the second one is fixed by this.

* SystemAdminUser was not part of the channel

Some tests are failing because SystemAdminUser is not part of the
team and channels.
This commit adds user to team and channels, in an effort to fix
api4/user_tests

* Fixes tests

* Fixes tests

* Addresses review comments

* Fix if clause

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-02-09 15:41:30 -05:00
Ben Schumacher
6dab9eadf8 [MM-40935] Add OnInstall() plugin hook (#19499) 2022-02-09 20:29:00 +01:00
Kirill Krotov
440790dad6 [MM-39631] mirgate user store to sqlx (#19403)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-02-09 19:56:16 +05:30
Allan Guwatudde
e27099ec03 [MM-41534] - Portal not picking up MMCLOUDURL cookie (#19515) 2022-02-08 20:07:16 +03:00
Gabe Jackson
03d059bd2a Skip and warn on emoji import when name conflicts with system emoji (#19516)
This changes import behavior related to emoji imports when the name
conflicts with the name of a system emoji. Previously, the import
would fail, but now a warning is logged and the conflicting emoji
is skipped.
2022-02-08 10:20:34 -05:00
Agniva De Sarker
6605300c66 MM-41085: Use a counting semaphore in sendNotifications (#19498)
We throttle the concurrency limit in maintaining thread membership
for a given thread using a counting semaphore. The limit is currently
8 which is a decent number to start with.

On some more thinking, it would be even better if the sql query
could be modified to support batch updates.

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

```release-note
NONE
```
2022-02-08 12:20:02 +05:30
Gabe Jackson
ca8eb1347b Skip exporting channels for deleted teams (#19494)
This corrects a bug where exports that contained deleted teams
could fail to import. Channels must be skipped that belong to these
deleted teams in order to produce a valid import bundle.
2022-02-07 12:24:50 -05:00
Julien Tant
d2cabaebab [MM-41343] Password reset must be 24hour (#19484) 2022-02-05 13:52:34 -07:00
Shivashis Padhi
4ebf0df545 [MM-40582] Send unsanitized user to source on user_updated (#19444)
- feat: On user_updated event, send unsanitized user to event source and send sanitized event to other users
 - tests: Add tests for user_updated event changes

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-02-03 11:28:01 +05:30
Ben Schumacher
321b19e3db [MM-41290] Add Endpoint to complete onboarding (#19435) 2022-02-02 19:45:09 +01:00
Agniva De Sarker
a733fb840d GraphQL (part 1): Store layer (#19465)
We add the necessary store methods to use GraphQL

```release-note
NONE
```
2022-02-02 22:44:22 +05:30
Ben Cooke
e09345798e Growth spike: Get latest MM version (#19366)
* tools updates

* Revert "tools updates"

This reverts commit 6293297b55803c5a263e200ebd80192899666ae9.

* new endpoint to fetch the latest release information

* adding unit tests

* fixing tests and adding check for github response

* error translations

* fixing translations

* chaning error log

* changing cache size

* empty strings for translations

* changing size to 1

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-02-02 09:19:47 -05:00
Ashish Bhate
58879719f2 [MM-41350] All CRT server operations should only happen if ThreadAutoFollow is true (#19411)
Summary
CRT server book-keeping should only happen if ThreadAutoFollow is true.

Ticket Link
https://mattermost.atlassian.net/browse/MM-41350
2022-02-01 17:56:42 +05:30
Ashish Bhate
ae16f51aea [MM-41351] Set ThreadAutoFollow to false by default (#19441)
Summary
ThreadAutoFollow is now false by default. Won't affect existing systems that have it set to true.

Ticket Link
https://mattermost.atlassian.net/browse/MM-41351
2022-02-01 16:21:04 +05:30
Kyriakos Z
e23a7a2311 MM-40664: fixes CRT notifications (#19328)
* MM-40664: fixes CRT notifications

Reply notification settings that take effect when CRT is off where
considered when CRT is on as well. Resulting, in some cases, in not
respecting the CRT setting for notifications.
This commit fixes that by guarding against IsCRTEnabledForUser when
checking for reply notification settings.

* Adds test cases

* Satisfies the vet

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-01-31 10:47:18 -05:00
Ibrahim Serdar Acikgoz
e03384c4d1 [MM-40712] config: Bugfix on path resolution; fail if given config does not exist (#19360)
* config: bugfix on path resolution; fail if given config does not exist

* reflect review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-01-31 17:15:32 +03:00
Agniva De Sarker
7988810fc0 Disable sentry tracing completely (#19410)
We don't do instrumentation of Sentry transactions
anywhere in the code. Only opentracing code is present.

One has to explicitly add custom instrumentation for it
to work: https://docs.sentry.io/platforms/go/performance/instrumentation/custom-instrumentation/

It's likely someone is running custom code and sending
transaction data to Sentry. It's not super hard to pick
off the sentry DSN string from the binary.

The PR is more of a best effort to stop any future
transaction events to be sent.

```release-note
NONE
```
2022-01-28 12:47:46 +05:30
Agniva De Sarker
0c9262c4d1 MM-41236: Sentry crash: Fix nil reference to token (#19417)
The AND condition would mean that it would try to dereference
token.Valid if there was an error. And there's no guarantee
to always have a non-nil token in case of an error. We need
to track those conditions separately.

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

```release-note
NONE
```
2022-01-28 12:37:02 +05:30
Ashish Bhate
7026818f80 MM-35298: Follow thread when added to channel (#19311)
* MM-35298: Follow thread when added to channel

* return better error if thread doesn't exist

* update test for possible race

* use correct comparision operator
2022-01-25 14:44:18 -05:00
Scott Bishel
956e21cfa2 Boards data retention (#19262)
* add Boards to DataRetention, add hook for data retention

* remove replaces

* update hook to remove parameter

* add boards data retention to telemetry

* fix unit test

* update test, update hooks

* update RunDataRetention server version

* put behind a feature flag

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-01-20 17:46:03 -07:00
Josh Soref
294bd44971 [GH-19267] Spelling comments (#19268)
* spelling: comments

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-01-20 10:07:27 +05:30
Agniva De Sarker
3207d861ca MM-40880: Sentry crash: MarkChannelAsUnread (#19370)
Use the correct error variable to prevent crash

The errors.As check has been removed because ThreadStore.Get
returns a nil error if no thread is found and that's how
the application logic is written. So the check was redundant.

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-01-20 09:11:03 +05:30
Scott Bishel
5e147dd150 remove BoardsUnfurl feature flag (#19283) 2022-01-17 10:11:01 -07:00
Allan Guwatudde
ee92bda912 [MM-41022] - Fix panic when AllowCookiesSubdomain setting is false (#19339)
* [MM-41022] - Cloud: Panic after log in when AllowCookiesSubdomain setting is false

* remove print

* improvement

* remove configration setting from flow

* fix tests

* feedback impl

* feedback impl
2022-01-17 18:50:40 +03:00
Ashish Bhate
a55bd001b4 Revert "[MM-37013] Async job to fix CRT channel unreads (#18340)" (#19319)
This reverts commit 0da249c651.
2022-01-12 18:51:47 +05:30
Allan Guwatudde
664af506a3 [MM-39583] - Intermediary web login page: Workspace Cookies (#19256)
* [MM-39583] - Intermediary web login page: Workspace Cookies

* only cloud

* fix error with license check

* feedback impl

* improvement

* make improvements

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-01-12 10:31:46 +03:00
Claudio Costa
0bd19e682c Sanitize message in email template (#19304) 2022-01-11 11:40:00 +01:00
Yusuke Nemoto
c8198fbefe Added support for exporting and importing the type and edit_at of a post (#18992)
* feat: add Type/EditAt field to PostImportData

* test: add tests

* feat: add Type/EditAt field to ReplyImportData

* chore: fix lint error

* test: fix failed tests

* test: refactoring

* test: fix how to assertion

* test: fix failed case which depends on accidental order of replies
2022-01-08 09:37:07 +05:30
Ben
9ba020db2e [MM-40560] Add Server locale to link preview request (#19156)
* Add Server locale to link preview request

* Update unit tests for post embed
2022-01-05 17:32:36 -05:00
Kirill Krotov
0dbc74f6d5 [GH-18965] - Pass expire time from outside Cleanup method (#19008)
Pass expire time from outside Cleanup method

Fixes #18965
2021-12-22 14:57:30 +05:30
Allan Guwatudde
81409ee7c4 [MM-40407] - Do not show the Renew Now if the license id does not exist in the portal (#19188)
* [MM-40407] - Do not show the Renew Now if the license id does not exist in the portal

* improvements

* impl mock

* fix translations

* feedback impl

* fix typo

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-12-21 09:46:02 +03:00
Ben Schumacher
34c4e543f9 [MM-39999] Increase key length in plugin KV store to 150 (#19002) 2021-12-20 13:13:50 +01:00
Agniva De Sarker
8b155e34c7 Re-initialize plugins only when needed (#19158)
Previously, for every config change, we would re-initialize
plugins irrespective of whether there would be any actual
plugin related changed or not.

Now, we compute the difference between previous and new configs
and check whether there has been any changes to plugin related
configuration, and re-init plugins only if that's true.

This improves performance as plugin re-initialization is quite
costly.

https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4/bed59298-27da-4b74-8be5-cdeb4c50c3e2
```release-note
NONE
```
2021-12-17 20:15:17 +05:30
Allan Guwatudde
0b1e9445c8 [MM-40682] - SIGSEGV after upgrade from 6.1.0 to 6.2.0 (#19192)
* [MM-40682] - SIGSEGV after upgrade from 6.1.0 to 6.2.0

* feedback impl
2021-12-17 09:39:10 +03:00
Allan Guwatudde
5aba3bb9e2 Improve gif processing (#19164)
* Improve gif processing

* feedback impl
2021-12-15 19:07:24 +03:00