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

2148 Коммитов

Автор SHA1 Сообщение Дата
Doug Lauder
00aeca0e5c MM-26064 - ENV var license override (#14943)
* License provided through env var takes precedence over other license sources
2020-07-01 13:27:37 -04:00
Hossein Ahmadian-Yazdi
4c50c7c59b [MM-25780] Fix incorrect session length when logging in through mobile using SSO (#14874)
* Pass device ID

* dont use device id as way of detecting

* fix spelling mistake

* update layers

* fix test

* fix linting

* save schema

* put columns in correct place

* fix linting

* update

* upgrade go change

* use props

* fix stuff

* update session tests

* address PR comments

* address PR comments
2020-06-30 10:34:05 -04:00
Ben Schumacher
43f7acd45a [MM-26507] Send license type for install plugin request (#14913) 2020-06-30 14:17:00 +02:00
Ben Schumacher
a34ea6ad63 [MM-26463] Keep query parameter for interplugin requests (#14905) 2020-06-30 10:13:27 +02:00
Agniva De Sarker
08457860cc MM-26571: Move the semaphore creation before hub start (#14938)
This avoids the race of assigning the sema field from the start method
which runs in a goroutine.

The race that happens is

==================

WARNING: DATA RACE
Write at 0x00c003a9d1b0 by goroutine 67:
  github.com/mattermost/mattermost-server/v5/app.(*PushNotificationsHub).start()
      /home/agniva/mattermost/mattermost-server/app/notification_push.go:264 +0x90

Previous read at 0x00c003a9d1b0 by goroutine 69:
  github.com/mattermost/mattermost-server/v5/app.(*Server).createPushNotificationsHub()
      /home/agniva/mattermost/mattermost-server/app/notification_push.go:260 +0x1d5
2020-06-30 13:15:05 +05:30
Jesús Espino
e2e352e223 Change the App dependency with Server in migrations package (#14804)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-29 18:00:16 +02:00
Agniva De Sarker
a9ba052207 MM-26206: Add GroupMentions permissions in default channel admin (#14838)
* MM-26206: Add GroupMentions permissions in default channel admin

This permission was skipped from the default permissions function.
Which led to a bug where permissions reset would not bring back
this permission to the different roles.

* Added tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-29 21:04:29 +05:30
Jesús Espino
05dc928576 Better handling of errors on trial license request (#14886)
* Fix behavior on blank site url on trial requests

* Adding trial license error response handling

* Changing text based on PR review comments
2020-06-29 17:22:50 +02:00
Farhan Munshi
9e12a34e3c [MM-25568] LDAP Sync skip users and log when they dont match the restricted email of a team or channel (#14895)
* Dont return an error if createDefaultChannelMemberships fails due to email domain restriction on team

* Add test ensuring sync works as intended and only skips over failed users

* Remove unneeded line

* Update wording

* Trigger CI
2020-06-29 10:42:03 -04:00
Christopher Poile
4bfad26614 MM-26441 - fix for doPluginRequest (#14897)
* merge rawQuery params with provided values

* tests for doPluginRequest

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-26 11:15:04 -03:00
Claudio Costa
d0e035467c [MM-16473] Make plugins' ServerHTTP http.ResponseWriter hijackable (#14822)
* Make plugins' ServerHTTP http.ResponseWriter hijackable

* Rename brw to align with docs

* Fix error handling
2020-06-26 10:51:23 +02:00
Rodrigo Villablanca
0118db9d23 Migration of AuditStore to return plain errors (#14825)
Automatic Merge
2020-06-26 06:26:35 +02:00
Siyuan Liu
aaea36a24d MM-25115 - make cacheProvider2 accessible to localcachelayer (#14691)
* make cacheProvider2 accessible to localcachelayer

* migrate localcachelayer

* revert test.sh

* workaround gob deserialization issue

* fix web_test.go

* merge conflicts

* resolve merge conflicts

* revert back test workaround

* fix the wrong merge
2020-06-25 17:08:53 +05:30
Agniva De Sarker
1648b11e82 MM-25507: Remove old migration state marker before running fresh migration (#14768)
While resetting permissions, we were not removing old migration state residue
for the EMOJIS_PERMISSIONS_MIGRATION_KEY and GUEST_ROLES_CREATION_MIGRATION_KEY.
Therefore, during their migration, they got skipped because the code checks
if a migration key is already present or not.

To fix this, we remove the migration key just as we do for ADVANCED_PERMISSIONS_MIGRATION_KEY.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-25 13:36:47 +05:30
Agniva De Sarker
3cf05efdd9 MM-25404: Add GetHealthScore metric for the cluster (#14767)
* MM-25404: Add GetHealthScore metric for the cluster

This PR adds the necessary function to the cluster interface
so that they can be called from App code.

* Add mocks

* Remove fakeapp

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-24 18:46:33 +05:30
Rodrigo Villablanca
64d12c08e9 LicenseStore migration to return plain errors (#14837)
Automatic Merge
2020-06-24 05:56:35 +02:00
Maria A Nunez
668a2aa856 Added SearchPostsInTeamForUser for plugin API (#14807)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 21:58:44 -04:00
Christopher Speller
574b48835d MM-26055 Remove session requirement from command args. (#14880)
* Remove session requirement from command args.

* Removing unused server side translation.

* Restoring model.CommandArgs.Session for compatibility.

* Feedback fixes.

* Build fix

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 08:33:45 -07:00
Rodrigo Villablanca
7bf6565ed2 Migration of SchemeStore to return plain errors (#14836)
Automatic Merge
2020-06-23 06:56:35 +02:00
Agniva De Sarker
a1547cfac5 MM-19548: Add a deadlock retry function for SaveChannel (#14857)
* MM-19548: Add a deadlock retry function for SaveChannel

A deadlock has been seen to occur in the upsertPublicChannelT method
during bulk import.

Here is a brief excerpt:

*** (1) TRANSACTION:
TRANSACTION 3141, ACTIVE 1 sec inserting
INSERT INTO
                            PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
                        VALUES
                            (?, ?, ?, ?, ?, ?, ?)
                        ON DUPLICATE KEY UPDATE
                            DeleteAt = ?,
                            TeamId = ?,
                            DisplayName = ?,
                            Name = ?,
                            Header = ?,
                            Purpose = ?
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3141 lock_mode X locks gap before rec insert intention waiting
** (2) TRANSACTION:
TRANSACTION 3140, ACTIVE 1 sec inserting
mysql tables in use 1, locked 1
5 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 2
MySQL thread id 50, OS thread handle 140641523848960, query id 3226 172.17.0.1 mmuser update
INSERT INTO
                            PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
                        VALUES
                            (?, ?, ?, ?, ?, ?, ?)
                        ON DUPLICATE KEY UPDATE
                            DeleteAt = ?,
                            TeamId = ?,
                            DisplayName = ?,
                            Name = ?,
                            Header = ?,
                            Purpose = ?
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3140 lock_mode X locks gap before rec

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 76 page no 4 n bits 104 index Name of table `mydb`.`PublicChannels` trx id 3140 lock_mode X locks gap before rec insert intention waiting

*** WE ROLL BACK TRANSACTION (1)

Following is my analysis:

From the deadlock output, it can be seen that it's due to a gap lock.
And that's clear because the index is Name which is a multi-column index using Name and TeamId.
But interestingly, both transactions seem to be inserting the same data, which is what is puzzling me.
The multi-column index on Name and TeamId will guarantee that they are always unique. And from looking at the code,
it does not seem possible to me that it will try to insert the same data from 2 different transactions.
But even if they do, why does tx 2 try to acquire the same lock again when it already has that ?

Here is what I think the order of events happening

Tx 2 gets a gap lock.
Tx 1 tries to get the same gap lock.
Tx 2 tries to again get the same gap lock ?

The last step is what is puzzling me. Why does an UPSERT statement acquire 2 gap locks ? From my reading of https://dev.mysql.com/doc/refman/8.0/en/innodb-locks-set.html:

> INSERT ... ON DUPLICATE KEY UPDATE differs from a simple INSERT in that an exclusive lock rather than a shared lock is placed on the row to be updated when a duplicate-key error occurs. An exclusive index-record lock is taken for a duplicate primary key value. An exclusive next-key lock is taken for a duplicate unique key value.

From what I understand, the expectation is that there will be one X lock and one gap lock is taken.
But that's not what the deadlock output seems to say.

The general advice on the internet seems to be that deadlocks will happen and not all of them can be understood.

For now, we add a generic deadlock retry function at the store package which can be reused by other queries too.

P.S.: This is a verbatim copy of my investigation posted at https://dba.stackexchange.com/questions/268652/mysql-deadlock-upsert-query-acquiring-gap-lock-twice

Testing:

This is ofcourse hard to test because it is impossible to reproduce this. I have tested this by manually returning an error
and confirming that it indeed retries.

WARN[2020-06-19T11:18:24.9585676+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.959158+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.9595072+05:30] A deadlock happened. Retrying.                caller="sqlstore/channel_store.go:568" error="Error 1213: mydeadlock"
WARN[2020-06-19T11:18:24.9595451+05:30] Deadlock happened 3 times. Giving up          caller="sqlstore/channel_store.go:579"
ERRO[2020-06-19T11:18:24.9596426+05:30] Unable to save channel.                       caller="mlog/log.go:175" err_details="Error 1213: mydeadlock" err_where=CreateChannel http_code=500 ip_addr="::1" method=POST path=/api/v4/channels request_id=745bsj13b7f6mnmsbn3t97grbw user_id=xcof1ipipbrfxpfjf6x4p6kx9e

* Fix tests

* Address review comments

* Address review comments

* Add forgotten test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-23 08:44:39 +05:30
Agniva De Sarker
78d44f3eab MM-25701: Reuse HTTP client in sendAckToPushProxy (#14759)
We reuse the http client made for push notifications.
This leads to reuse of TCP connections rather than
creating a new client every time.
2020-06-23 00:08:06 +05:30
Ibrahim Serdar Acikgoz
124014ad9c [MM-23719] api4/channel: add move channel to a team endpoint (#14246)
* api4: add move channel method

* api4: add tests for move channel, model: add move channel to client4.go

* add api.channel.move_channel.type.invalid message

* model/client4: remove a redundant line

* api4/channel: add tests for gm and private channel types

* app/channel: update move channel comment

* app/channel: add extra check if a users joins to channel during movement

* app/channel: log errors for post move channel

* app/channel: remove deactivated members by default while moving a ch.

* model/client: update move channel command

* fix vet errors

* app/channel: add missing webhook updates

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-22 16:57:49 +03:00
George Goldberg
e5addef19b MM-23574: Remove Segment. (#14712)
* MM-23574: Eliminate Segment.

* Update dependencies.

* Fix review suggestions.
2020-06-22 08:35:03 +01:00
Martin Kraft
6158e91308 MM-25261: Add 'include_deleted' parameter to get all channels API req… (#14721)
* MM-25261: Add 'include_deleted' parameter to get all channels API request.

* MM-25261: Adds test for deleted channels.

* MM-25261: Switches to single liner.

* MM-25261: Adhere to beta config setting for viewing archived channels.

* MM-25261: Test fix.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-19 16:53:37 -04:00
Rodrigo Villablanca
d391fd6231 Migration of ChannelStore.GetMoreChannels to return plain error (#14811)
Automatic Merge
2020-06-19 20:26:35 +02:00
Rodrigo Villablanca
2760497660 Migration of UserTermsOfServiceStore to return plain errors (#14788)
* Migration of UserTermsOfService Store

* Ordering translations file

* Fix imports

* Fix translations]

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-19 17:49:30 +05:30
Martin Kraft
88a6cf0bf1 MM-26231: Reverts plugin API breaking change. (#14852) 2020-06-18 14:17:36 -04:00
Farhan Munshi
77bee1d4f1 MM-25263 Add group members to search and get users and create getGroupStats endpoint (#14733)
Add tests for SearchInGroup
2020-06-18 10:22:35 -04:00
Rodrigo Villablanca
8dc7c5762f Migrate GetDeletedByName from ChannelStore to return error interface (#14709)
Automatic Merge
2020-06-18 06:26:35 +02:00
Agniva De Sarker
1d9c8a490d MM-25700 : Use a counting semaphore for push notifications hub (#14758)
Automatic Merge
2020-06-18 05:56:35 +02:00
Doug Lauder
b317ee5cf2 MM-25394 session expired push notifications (#14732)
* new job type created that checks for expired mobile sessions and pushes notifications.

* only send session expired notifications if ExtendSessionLengthWithActivity is enabled.

* includes schema change:  field added to Sessions table
2020-06-17 14:47:54 -04:00
Jesús Espino
61ff43aef8 Moving back saml to the fakeapp approach (#14833)
* Moving back saml to the fakeapp approach

* Configure sp during initialization

* Configure sp during initialization (with no fake app)
2020-06-16 23:37:06 +02:00
Attila Molnar
66597d0fcb Expand Plugin and REST APIs to trigger user typing event (#14331) 2020-06-16 11:41:05 +02:00
Nisheet Sinvhal
8c1164d86b Pass query string params to interactive dialog request url (#14366) 2020-06-16 11:31:55 +02:00
Rodrigo Villablanca
e342b5a2f2 Migrate multiples methods from ChannelStore to return error interface (#14708)
Automatic Merge
2020-06-16 10:56:35 +02:00
Jesús Espino
92c98dac3e Remove RunOldAppInitialization (#14803) 2020-06-15 09:44:17 +02:00
Miguel de la Cruz
4bc859433b [MM-24604] Migrate get channel and get channel by name endpoints to local mode (#14547)
* add unix socket listener for mmctl local mode

* First working PoC

* Adds the channel list endpoint

* Add team list endpoint

* Add a LocalClient to the api test helper and start local mode

* Add helper to test with both SystemAdmin and Local clients

* Add some docs

* Adds TestForAllClients test helper

* Incorporating @ashishbhate's proposal for adding test names to the helpers

* [MM-24146] Add unix socket listener for mmctl local mode (#14296)

* add unix socket listener for mmctl local mode

* add a constant for local-mode socket path

* reflect review comments

* Fix init errors after merge

* Adds create channel tests

* Always init local mode to allow for enabling-disabling it via config

* Check the RemoteAddr of the request before marking session as local

* [MM-24604] Migrate get channel and get channel by name endpoints to local mode

* Remove local test conditional

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2020-06-14 10:31:20 +02:00
Ben Schumacher
81a87533a9 [MM-25607] Correctly log if plugin icon is invalid (#14679) 2020-06-13 09:51:45 +02:00
Jesús Espino
ac4c675a19 Fixing plugin routes (#14805)
Automatic Merge
2020-06-12 22:26:35 +02:00
Jesús Espino
f5eab1271b Removing all FakeApp usages (#14174)
* Removing some other fake apps

* More FakeApp removed

* Removing entirely FakeApp

* Fixing some tests

* Fixing get Cluster id from get plugin status

* Fixing failing tests

* Fixing tests

* Fixing test initialization for web

* Fixing InitServer for server tests

* Fixing InitServer for server tests

* Reverting go.sum and go.mod

* Removing unneded HTMLTemplates function in App layer

* Moving back some functions to its old place to easy the review

* Moving back some functions to its old place to easy the review

* Using the last struct2interface version

* Generating store layers

* Fixing merge problems

* Addressing PR comments

* Small fix

* Fixing app tests build

* Fixing tests

* fixing tests

* Fix tests

* Fixing tests

* Fixing tests

* Fixing tests

* Moving license to server struct

* Adding some fixes to the test compilation

* Fixing cluster and some jobs initialization

* Fixing some license tests compilation problems

* Fixing recursive cache invalidation

* Regenerating app layers

* Fix test compilation

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-12 13:43:50 +02:00
Ashish Bhate
f3ac33e6dc MM-25078: local mode for createUserAccessToken, revokeUserAccessToken and getUserAccessTokensForUser (#14680)
Summary
- local mode for createUserAccessToken
- local mode for revokeUserAccessToken
- local mode for getUserAccessTokensForUser, also removed a duplicate test.

Ticket Link
- https://mattermost.atlassian.net/browse/MM-25078
- https://mattermost.atlassian.net/browse/MM-25079
- https://mattermost.atlassian.net/browse/MM-25080
2020-06-12 16:29:05 +05:30
waqas razzaq
7787998bee MM-23408: Added channel ID check for Plugin API UploadFile (#14138)
* Added 2 checks for app/file.go
- Check if channel id exist
- Check if user has permission to the upload file to the channel

Also added translations for 2 errors defined in app/file.go

* fixed 1 failing test that was linked with UploadFile

* Fixed small issue, according to the review.

* missed 1 review item. Just updated the code for it.

* fix 1 failing test, assuming that the file upload is required. ignoring nouser idea.

Added the translation for english for 2 newly defined errors.

* removed new line

* trying to fix the translation issue. Added the missing translations from master.

* as per discussion, we need to revert the check for user channel permission. So reverted it.

* Update app/file_test.go

Co-Authored-By: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>

* Update i18n/en.json

Co-Authored-By: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>

* Update file.go

Move the check to the top of the method.

* go fmt

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2020-06-12 12:21:18 +02:00
Ashish Bhate
d5e9fde8d7 MM-24865: local mode for some user handlers (#14511)
Summary
- Local mode handler for createUser
- Local mode handler for updateUser
- Local mode support for updateUserRoles
- Local mode support for sendPasswordReset
- Local mode support for updateUserMfa
- Local mode support for updateUserActive

Ticket Link
- https://mattermost.atlassian.net/browse/MM-24865
- https://mattermost.atlassian.net/browse/MM-24869
- https://mattermost.atlassian.net/browse/MM-24866
- https://mattermost.atlassian.net/browse/MM-24868
- https://mattermost.atlassian.net/browse/MM-24870
- https://mattermost.atlassian.net/browse/MM-25041
2020-06-12 12:05:09 +05:30
Eli Yukelzon
11812ae8e4 MM-25450 deleted posts should be sanitised (#14769) 2020-06-11 13:12:13 +03:00
Rodrigo Villablanca
41d9c673cf Migrate GetChannels method from ChannelStore to return error interface (#14711)
* Migrate GetChannels method from ChannelStore to return error interface

* Fix testing

* Changed error type: ErrInvalidInput -> ErrNotFound

* Added note about error migrations

* Fix en.json

* Fix i18n

Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2020-06-11 14:02:03 +05:30
Rodrigo Villablanca
9b0ae49b55 Migrate GetDeleted method from ChannelStore to return error interface (#14710)
* Migrate GetDeleted method from ChannelStore to return error interface

* Moving i18n translations to the correct place

Co-authored-by: Jesús Espino <jespinog@gmail.com>
2020-06-11 09:37:37 +05:30
Ashish Bhate
f2253df8a1 MM-25083: local mode for patchBot, getBots, enableBot, disableBot and assignBot (#14652)
* local mode for patchBot
* local mode for getBots
* local mode for enableBot and disableBot
* local mode for assignBot
2020-06-10 15:25:14 +05:30
Jason Frerich
deeba8f609 add plugin telemetry (#14772)
* add plugin telemetry

* correct confluence id
2020-06-09 15:36:18 -05:00
Rodrigo Villablanca
cac154e62b Migrate GetAllChannels and GetAllChannelsCount from ChannelStore to r… (#14765)
* Migrate GetAllChannels and GetAllChannelsCount from ChannelStore to return plain errors

* Moving i18n translations to the correct place

Co-authored-by: Jesús Espino <jespinog@gmail.com>
2020-06-09 21:48:01 +05:30
George Goldberg
921cff0e60 MM-24483: Add telemetry for new config settings. (#14773) 2020-06-09 09:04:52 +01:00