Commit Graph

12546 Commits

Author SHA1 Message Date
Rodrigo Villablanca
d391fd6231 Migration of ChannelStore.GetMoreChannels to return plain error (#14811)
Automatic Merge
2020-06-19 20:26:35 +02:00
Mario de Frutos Dieguez
4a974eabea Include response log trace (#14841)
Include the status_code in the log trace
2020-06-19 16:34:49 +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
Ashish Bhate
d21f1183ab MM-25118: fix teamImport panic and return better error (#14797)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-19 17:23:26 +05:30
Mario de Frutos Dieguez
0a96ed04a3 ES now supports inactive users filtering (#14463)
* ES now supports inactive users filtering
2020-06-18 21:17:35 +02:00
Agniva De Sarker
22aff2af4a MM-26203: Fix TestChannelStore//SearchAllChannels flake (#14840)
* MM-26203: Fix TestChannelStore//SearchAllChannels flake

Using random strings for channel names creates chances of collisions
when searching for specific strings.

We increase the search space increasing the size of the search string
to be searched. This reduces collisions and makes the tests more reliable.

For the "off-" family of tests, this probably needs more length. But
it would also need the tests to be changed slightly as the "off-" part
acts as a prefix. I accidentally stumbled upon it while running the test
50 times. Adding a "-" is probably good enough for now. We can revisit
if it fails again in CI.

* improved team_store tests too
2020-06-18 15:14:34 -04:00
Martin Kraft
88a6cf0bf1 MM-26231: Reverts plugin API breaking change. (#14852) 2020-06-18 14:17:36 -04:00
Farhan Munshi
4d40226e02 MM-24674 Update channel members by group to look at distinct timezones correctly (#14673)
* MM-24674 Update channel members by group to look at distinct autoTimezone and manualTimezone.

Instead of just doing a blanket distinct on the column since that returns more entries than expected

* Use JSON extract instead of parsing text

* Use single quotes in mysql query too

* Dont need to prepend users on unambiguous column

* Use json extract instead of shorthand

* Dont count timezone if timezone default length

* CI

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-18 12:02:00 -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
Mario de Frutos Dieguez
f6c934d7e0 Create GetOldestEntityCreationTime method (#14515)
This method will be used by the ES index jobs in order
to get the first timestamp to be used as the starting point
when doing indexing tasks
2020-06-18 14:34:23 +02:00
Agniva De Sarker
ef85001523 MM-25710: Use an efficient cache serialization algorithm (#14826)
* MM-25710: Use an efficient cache serialization algorithm

We investigate 3 packages for selecting a suitable replacement
for gob encoding. The algorithm chosen was msgpack which gives
a decent boost over the standard gob encoding.

Any external schema dependent algorithms like protobuf, flatbuffers, avro,
capn'proto were not considered as that would entail converting the model structs
into separate schema objects and then code generating the Go structs.
It could be done theoretically at a later stage specifically for structs
which are in the hot path. This is a general solution for now.

The packages considered were:
- github.com/tinylib/msgp
- github.com/ugorji/go/codec
- github.com/vmihailenco/msgpack/v5

msgp uses code generation to generate encoding/decoding code without the reflection overhead.
Theoretically, therefore this is supposed to give the fastest performance. However, a major
flaw in that package is that it works only at a file/directory level, not at a package level.
Therefore, for structs which are spread across multiple files, it becomes near to impossible
to chase down all transitive dependencies to generate the code. Even if that's done, it fails
on some complex type like xml.Name and time.Time. (See: https://github.com/tinylib/msgp/issues/274#issuecomment-643654611)

Therefore, we are left with 2 choices. Both of them use the same underlying algorithm.
But msgpack/v5 wraps the encoders/decoders in a sync.Pool. To make a perfect apples-apples
comparison, I wrote a sync.Pool for ugorji/go/codec too and compared performance.

msgpack/v5 came out to be the fastest by a small margin.

benchstat master.txt ugorji.txt
name               old time/op    new time/op    delta
LRU/simple=new-8     5.62µs ± 3%    3.68µs ± 2%  -34.64%  (p=0.000 n=10+10)
LRU/complex=new-8    38.4µs ± 2%     9.1µs ± 2%  -76.38%  (p=0.000 n=9+9)
LRU/User=new-8       75.8µs ± 2%    23.5µs ± 2%  -69.01%  (p=0.000 n=10+10)
LRU/Post=new-8        125µs ± 2%      21µs ± 3%  -82.92%  (p=0.000 n=9+10)
LRU/Status=new-8     27.6µs ± 1%     5.4µs ± 4%  -80.34%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
LRU/simple=new-8     3.20kB ± 0%    1.60kB ± 0%  -49.97%  (p=0.000 n=10+10)
LRU/complex=new-8    15.7kB ± 0%     4.4kB ± 0%  -71.89%  (p=0.000 n=9+10)
LRU/User=new-8       33.5kB ± 0%     9.2kB ± 0%  -72.48%  (p=0.000 n=10+8)
LRU/Post=new-8       38.7kB ± 0%     4.8kB ± 0%  -87.48%  (p=0.000 n=10+10)
LRU/Status=new-8     10.6kB ± 0%     1.7kB ± 0%  -83.50%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
LRU/simple=new-8       46.0 ± 0%      20.0 ± 0%  -56.52%  (p=0.000 n=10+10)
LRU/complex=new-8       324 ± 0%        48 ± 0%  -85.19%  (p=0.000 n=10+10)
LRU/User=new-8          622 ± 0%       108 ± 0%  -82.64%  (p=0.000 n=10+10)
LRU/Post=new-8          902 ± 0%        74 ± 0%  -91.80%  (p=0.000 n=10+10)
LRU/Status=new-8        242 ± 0%        22 ± 0%  -90.91%  (p=0.000 n=10+10)

11:31:48-~/mattermost/mattermost-server/services/cache2$benchstat master.txt vmi.txt
name               old time/op    new time/op    delta
LRU/simple=new-8     5.62µs ± 3%    3.68µs ± 3%  -34.59%  (p=0.000 n=10+10)
LRU/complex=new-8    38.4µs ± 2%     8.7µs ± 3%  -77.45%  (p=0.000 n=9+10)
LRU/User=new-8       75.8µs ± 2%    20.9µs ± 1%  -72.45%  (p=0.000 n=10+10)
LRU/Post=new-8        125µs ± 2%      21µs ± 2%  -83.08%  (p=0.000 n=9+10)
LRU/Status=new-8     27.6µs ± 1%     5.1µs ± 3%  -81.66%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
LRU/simple=new-8     3.20kB ± 0%    1.60kB ± 0%  -49.89%  (p=0.000 n=10+10)
LRU/complex=new-8    15.7kB ± 0%     4.6kB ± 0%  -70.87%  (p=0.000 n=9+8)
LRU/User=new-8       33.5kB ± 0%    10.3kB ± 0%  -69.40%  (p=0.000 n=10+9)
LRU/Post=new-8       38.7kB ± 0%     6.0kB ± 0%  -84.62%  (p=0.000 n=10+10)
LRU/Status=new-8     10.6kB ± 0%     1.9kB ± 0%  -82.41%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
LRU/simple=new-8       46.0 ± 0%      20.0 ± 0%  -56.52%  (p=0.000 n=10+10)
LRU/complex=new-8       324 ± 0%        46 ± 0%  -85.80%  (p=0.000 n=10+10)
LRU/User=new-8          622 ± 0%       106 ± 0%  -82.96%  (p=0.000 n=10+10)
LRU/Post=new-8          902 ± 0%        89 ± 0%  -90.13%  (p=0.000 n=10+10)
LRU/Status=new-8        242 ± 0%        23 ± 0%  -90.50%  (p=0.000 n=10+10)

In general, we can see that the time to marshal/unmarshal pays off as the size of the struct
increases.

We can see that msgpack/v5 is faster for CPU but very slightly heavier on memory.
Since we are interested in fastest speed, we choose msgpack/v5.

As a future optimization, we can use a mix of msgpack and msgp for hot structs.
To do that, we would need to shuffle around some code so that for the hot struct,
all its dependencies are in the same file.

Let's use this in production for some time, watch grafana graphs for the hottest caches
and come back to optimizing this more once we have more data.

Side note: we have to do with micro-benchmarks for the time being, because all the caches
aren't migrated to cache2 interface yet. Once that's in, we can actually run some load tests
and do comparisons.

* Bring back missing import

* Fix tests
2020-06-18 17:21:39 +05:30
Maria A Nunez
085ab2c60a MM-25762 - Moved password settings to client limited configuration (#14777)
* Moved password settings to limited configuration

* Added unit test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-18 06:14:03 -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
Martin Kraft
2bb6071f73 MM-26065: Reverts Brotli encoding. (#14834)
* MM-26065: Reverts Brotli encoding.

* MM-26065: Removes package reference.
2020-06-16 18:15:31 -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
Agniva De Sarker
c58edbf622 MM-26167: improve CreatePostCheckOnlineStatus (#14827)
* Improve CreatePostCheckOnlineStatus

We improve the flakyness of the test by making the websocket
status checks synchronous after making each request.

This makes the status responses more reliable because in very
busy CI environments the goroutine scheduler can indeed send
the response which is made by a later HTTP request before the first one.

* Update api4/post_test.go

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2020-06-16 17:30:58 +05:30
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
Farhan Munshi
09a0b7db61 Clear team cache on delete team scheme (#14671)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-15 15:24:44 -04:00
Hossein Ahmadian-Yazdi
2c9c58ff50 [MM-25268] Implement prefix/suffix searching on teams and channel page in system console (#14698)
* Implement prefix/suffix search on teams page

* Make Channel Page prefix/suffix search as well

* address PR comments

* add tests

* fix styling

* take postgres into account

* add more api tests

* update test

* add team store test

* write store test for team and channel

* fix lint

* update description

* revert go mod

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-15 11:21:42 -04: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
Nisheet Sinvhal
f1c52387ae MM-25779 - Update apiTimerLayerTemplate and hooksTimerLayerTemplate to record error values (#14764)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-12 12:12:37 -04:00
Mario de Frutos Dieguez
033db51907 Remove UserStore.Get gorp usage (#14672)
We're removing the user of gorp in the most used queries
by our platform and this is one of them
2020-06-12 17:09:18 +02:00
Flavia Bastos
f912a93299 Document SqlTeamStore delete methods (#14785)
* Document SqlTeamStore delete methods

* Address feedback from code review: clarify permantDelete method
2020-06-12 13:46: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
8de5dd9022 MM-25075: local mode for getLogs (#14760) 2020-06-12 15:02:57 +05:30
Ashish Bhate
c58c0ba3dc MM-24440: Don't allow clearing the site url (#14694)
Summary
- If the site URL is set, don't allow clearing it.

Ticket Link
- https://mattermost.atlassian.net/browse/MM-24440
2020-06-12 14:00:11 +05:30
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
Agniva De Sarker
f30a62e303 MM-24876: local mode support for getPost (#14735)
Automatic Merge
2020-06-12 06:26:35 +02:00
Rodrigo Villablanca
172eb1853f Migrate PermanentDeleteByTeam method from ChannelStore to return erro… (#14707)
Automatic Merge
2020-06-11 17:26:35 +02:00
Shota Gvinepadze
77b468e456 [MM-25606] Make plugin API errors encodable (#14692)
* Make plugin API errors encodable

* Remove newlines

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-11 16:44:50 +04:00
Eli Yukelzon
11812ae8e4 MM-25450 deleted posts should be sanitised (#14769) 2020-06-11 13:12:13 +03:00
Miguel de la Cruz
28e58f7088 [MM-25950] Fix bleve error string (#14791)
Automatic Merge
2020-06-11 10:56:35 +02: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
Jason Frerich
a69c200574 update bundled plugins for server version 5.24 (#14727)
* update bundled plugins for server version 5.24

* github should be 1.0.0

* upgrade to welcomebot 1.2.0

* autolink 1.2.0 currently has breaking changes. revert to previous
version

* revert to jira 2.3.  users can still upgrade via marketplace

* correct the jira version

* revert to original versions.  Play conservative
2020-06-09 11:20:26 -07:00
Jesús Espino
9c9bdb8a90 Fix the reply count for pinned posts (#14744) 2020-06-09 18:42:59 +02: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
Ibrahim Serdar Acikgoz
779099d1a9 [MM-25715] services/mailservice: fix a flaky test (#14745)
* services/mailservice: fix a flaky test

* mailservice: reflect review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-09 13:47:04 +03:00
Elisabeth Kulzer
be44de22cf Docker compose network (#14783)
Automatic Merge
2020-06-09 11:17:18 +02:00