Commit Graph

1885 Commits

Author SHA1 Message Date
Eli Yukelzon
8e0fe90897 Thread fetching revert (#13616)
* Revert "MM-19371 - Reply count disappears from pinned and flagged conv… (#12753)"
2020-01-15 17:14:04 +02:00
Eli Yukelzon
e77ef9733c MM-20977 - Inviting multiple users with valid/allowed and inva… (#13372) 2020-01-14 15:29:50 +02:00
Rajat Varyani
51a61f6bc1 [MM-19720] Expose endpoint for config patch (#12997) 2020-01-14 13:06:17 +01:00
Ben Schumacher
1f3f8fbf57 [MM-21123] Add Labels to upstream Marketplace response (#13425)
* Add Labels to upstream Marketplace response

* Add LOCAL label to local plugins
2020-01-14 07:16:36 +01:00
Devin Binnie
8e2c59ca00 [MM-17155] Changes to email notifications to support Deep Linking page (#13362)
* Change link to redirect email notifications to landing page

* Fix to undefined variable

* Change `vault` to `landing`

* Added a couple tests

Co-authored-by: David Meza <dmeza@users.noreply.github.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-13 16:24:28 -05:00
Scott Bishel
aa0d0f9943 MM-21102: Add ExperimentalSettings.UseNewSAMLLibrary to diagnostics (#13543)
* add UseNewSAMLLibrary to diagnostics.go

* add UseNewSAMLLibrary to diagnostics.go

* add TRACK_CONFIG_EXPERIMENTAL to expected results

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-13 23:24:30 +05:30
Hossein Ahmadian-Yazdi
dc24c9abe8 [MM-20061] Add System Admin filter to both LDAP and SAML (#13534)
* promote user to admin upon login

* Add SAML support for admin accounts

* update en.json

* update i18n

* Add tests as per comments

* change function name

* fix config.go

* invalidate cache so its not checking for cache when roles change

* add enable attribute and filter
2020-01-13 12:50:01 -05:00
larkox
d4935fb22f [GH-13073] Migrate profilesInChannelCache cache from store/sqlstore/user_store.go to the new store/localcachelayer (#13536)
* Migrate profilesInChannelCache cache from store/sqlstore/user_store.go to the new store/localcachelayer

* Fix lint errors

* Remove unneeded cluster messages

* Remove unneeded cluster message registering

* Fix cluster messages

* Correct mistake with messages and restore model message
2020-01-11 17:52:44 +01:00
Martin Kraft
605040c597 MM-20644: Add users to teams as a SchemeAdmin based on a new configuration field on GroupTeams and GroupChannels records. (#13361)
* MM-20644: Add users to teams as a SchemeAdmin based on a new configuration field on GroupTeams and GroupChannels records.

* MM-20644: Adds SchemeAdmin to mapping of the GroupSyncable struct fields.

* MM-2064: Adds test to ensure SchemeAdmin field value is mapped.

* MM-20644: Adds missing index creation for fresh DBs.

* MM-20644: Duplicates UpdateMembersRole across Team and Channel stores. Adds tests.

* MM-20644: Fixes some old method name references.

* MM-20644: Moves variable declaration; removes Println statement.

* MM-20644: Use a SQL query instead of two to update Team and Channel members.

* MM-20644: Fixes tests; updates query.

* MM-20644: Fix permission check for patching a group syncable.

* MM-20644: Fixes test for change of permissions verification in group patch API request.

* MM-20644: Fix for ORM select vs insert.

* MM-20644: Linting fixes.

* MM-20644: Fixes some tests.

* MM-20644: Skips changing the role of guests.

* MM-20644: Added syncableID filtering
2020-01-10 09:19:39 -08:00
catalintomai
37ce413b7d MM-20698: Add server support for getting SAML metadata and updating S… (#13311)
* MM-20698: Add server support for getting SAMl metadata and updating SAMl settings
2020-01-09 21:25:20 -08:00
Agniva De Sarker
efffb790e4 MM-21608: Remove buggy migration code (#13600)
This code is old and not required to be present now.
2020-01-09 21:32:03 +05:30
Hector
62b57143c8 [MM 19840] Create a Cache Interface abstraction to support multiple cache backends (#13384)
* Refactor to use structured logging

* Properly formatted with gofmt

* created interface Cache, but construction of cache is still coupled.

* Implementing cache factories to build caches

* Simple redis implementation without error handling. Keys and values by default are string

* refactor NewLocalCacheLayer to inject cache factory

* Removed redis impl to focus on cache abstraction

* CacheFactory injected on sqlsupplier and saved in Store struct

* remove useless private method

* replace concrete declaration of lru cache to cache abstraction

* discard spaces

* Renamed factory to provider because concrete implementations of factories may hold an state (such as a redis client for example)

* refactor to include all caches in the same package cache and subpackages

* method close cache. This method will be used for concrete implementations that need to release resources (close a connection, etc)

* closing cacheprovider and releasing resources while closing sql store

* fixed merge conflict fail

* gofmt files

* remove unused property from post_store

* naming refactor to avoid stutter. Added godocs on interface

* Store doesnt know anything about the cache and provider. Cache provider will be built after loading config and injected in localCacheLayer

* fixed broken test

* cache provider initialized before RunOldAppInitialization which initializes the localcachelayer

* move statusCache to server to initialize it with the new cache provider

* update terms_service and channel_layer to have new cacheProvider

* gofmt

* Add Connect method to the cache provider

* mock cacheprovider in user_layer_test

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-09 09:57:28 +01:00
Allen Lai
1909fd6607 [MM-20804] Add "Unarchive Channel" option to the channel info screen (#13349)
* add websocket hooks to restoreChannel

* add userId to call in api4

* add constant

* undo changes in en.json

* add constants to en.json

* delete  code for deleting webhooks

* Update i18n/en.json

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>

* restore channel ordering

* delete Props

* Update app/channel.go

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>

* Update app/channel.go

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>

* change message format

* move WS message right after invalidate

* manually reorder en.json entry

* reorder en.json

* undelete to restore

* update en.json ordering

* update wording

* Update model/post.go

Co-Authored-By: Saturnino Abril <saturnino.abril@gmail.com>

* Update model/websocket_message.go

Co-Authored-By: Saturnino Abril <saturnino.abril@gmail.com>

* gofmt

* undeleted to restored

* add test to success case

* delete repeated test

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-09 09:42:29 +01:00
Jesús Espino
464c290e50 Removing certain unneded cluster invalidation messages (#13549)
* Removing certain unneded cluster invalidation messages

* Fixing typo

* Removing channges included in other PR

* Adding doc string to RegisterAllClusterMessageHandlers method

* fixing typos

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-08 11:31:10 +01:00
Agniva De Sarker
ecb41c6eb5 MM-21285: Remove environment overrides before config broadcast (#13527)
While sending the config broadcast message across a cluster, we would
include the environment overrides in the config.

We fix this by exposing a config config store method to remove the overrides,
and then calling that before saving the config across the cluster.

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-07 23:21:28 +05:30
Jesús Espino
092e53ace2 Fix inconsistencies in variable names for struct methods (#13561) 2020-01-07 10:47:03 +01:00
Vladimir Lebedev
5c6bdc357a MM-18384 - Migrate tests from "app/notification_test.go" to use testify (#13526)
* MM-18384 - Migrate tests from "app/notification_test.go" to use testify

* fix golangcibot

* fix golangcibot

* break complex comparisons into multiple simple statements

* make test cleaner

* add missing changes
2020-01-06 14:15:12 -05:00
Agniva De Sarker
88fecdb1a3 MM-21396: fix duplicate channel cluster invalidations (#13537)
While invalidating a channel, we send out a cluster message
from the app layer as well as from the localcachelayer.

This causes multiple redundant messages to be sent out.

And additionally multiple cluster handlers were being registered
from the app layer as well as the localcachelayer.

We fix this by removing the cluster broadcast from the app layer
and directly calling the store method. We also remove
the duplicate event handler registration.
2020-01-06 23:07:08 +05:30
Agniva De Sarker
e826055519 MM-21336: Improve channel rename restrictions (#13441)
* MM-21336: Improve channel rename restrictions

Non-direct channels should not have __ in them.

* Fix order of i18n extraction

* Incorporate review comments

Use a more relaxed check by actually checking for valid userIds.

* Improve error message
2020-01-03 20:56:32 +05:30
Shota Gvinepadze
69ab1ea1e4 [MM-20029] Fix incorrect bot message (#13392)
* Fix incorect bot message

* Edit whitespace
2020-01-03 18:31:13 +04:00
Agniva De Sarker
f75c8c7c9f MM-20225: Fix notification badge count for All Activity (#13353)
When push notification setting was selected to "All Activity", we were
just sending the unread count for the channel from where the message was sent
and not for all channels.

After discussion with @enahum and @migbot, we decided to keep the badge count
to only refer to mentions and not unread posts.

Therefore, we only take the unread count for the user irrespective of the
notify_props settings.

Updated the tests to reflect that.

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-01 13:46:51 +05:30
Agniva De Sarker
1e28ad4a73 MM-21209: Use the LRU cache for UserStore.Get call too (#13456)
* MM-21209: Use the LRU cache for UserStore.Get call too

We already have userProfileByIdsCache to store the user profiles by Id.
It just wasn't being used for the (*UserStore).Get method. We add a wrapper
method in LocalCacheUserStore to intercept that call and check for the
presence of the user Id in the cache.

There is no need to add any code for invalidation as all of that is already
present.

* Fix nil check for rootstore

* Fix TestUserStore test

Added an invalidate call. The invalidation was being done
from the app level. Hence we have to do it manually here for the test.
2019-12-30 09:22:31 -08:00
Renil Joseph
803a58f991 [MM-17422] Added code to update, delete last bot_icon time in model.bot. (#12229)
Display LHS bot Icon in web app. As part of mentioned task, Added LastIconUpdate variable in model.bot to store last update time of icon. Also added code to update/delete value of the mentioned variable when setting/deleting bot icon.
2019-12-29 15:30:18 +01:00
Claudio Costa
80dd2915db [MM-19914] Fix data races in WebSocketEvent (#13039)
* Make WebSocketEvent type immutable

* Update code to use updated immutable WebSocketEvent type

* Export WebSocketEvent fields and mark them as deprecated
2019-12-24 09:32:11 +01:00
Jesús Espino
b3e49ec45c Use require/assert.Empty instead of require/assert.Len(t, X, 0) (#13413) 2019-12-22 12:35:31 +01:00
Jesús Espino
fc9d49b2d2 MM-21254: Removing unnused/unnecesary getClientLicense etag (#13416) 2019-12-19 17:00:15 +01:00
Hossein Ahmadian-Yazdi
155ada09fb [MM-10858] Channel Member Update Websocket Event (#13305)
* Channel Member update event

* Address PR comments and extend tests

* golang ci addressed

* Update api4/channel_test.go

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>
2019-12-19 08:53:29 -05:00
Scott Bishel
be3e008dca MM-19867: - Implement allowing multiple SAML Libraries (#13299)
* Implement allowing multiple SAML Libraries

* fix unit tests

* updates based on review feedback

* Only set on startup, not config changes

* update unit tests, reload enterprise

* need to reset for previous tests

* update license statement

* fix licensing line
2019-12-18 15:35:53 -07:00
Martin Kraft
75ffd0b69e MM-14675: Eliminates implicit GroupChannel/GroupTeam associations. (#13199)
* MM-14675: Upserts GroupTeam when GroupChannel is linked.
MM-14675: Delete all associated GroupChannels when deleting a GroupTeam.
MM-14675: Using replica DB where possible.
MM-14675: Updates create method used in tests.

* MM-14675: Removes unnecessary DB retrieval of GroupSyncable record.
2019-12-18 08:54:09 -05:00
Jesús Espino
b8ef62e502 Adding structuredLogging check and fix inconsistencies (#13370)
* Adding structuredLogging check and fix inconsistencies

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments
2019-12-16 13:57:21 +01:00
Jesse Hallam
89c0b61bc3 MM-21103: change plugin signature path (#13360)
* MM-21103: change plugin signature path

Save as `<plugin_id>.tar.gz.sig` instead of `<plugin_id>.sig`. The latter was a relic of the previous design to support multiple plugin signatures, but now creates an inconsistency with how the original source files were supplied as `<some_name>.tar.gz` and `<some_name>.tar.gz.sig`.

Fixes: https://mattermost.atlassian.net/browse/MM-21103

* relax signature matches to avoid assuming signatures always exist
2019-12-12 13:45:55 -04:00
Jason Blais
6e275d0866 Add missing diagnostics for 5.18 release (#13358)
@hahmadia https://github.com/mattermost/mattermost-server/pull/13018
@sbishel https://github.com/mattermost/mattermost-server/pull/12362
@ali-farooq0 https://github.com/mattermost/mattermost-server/pull/13017
2019-12-12 09:17:31 -05:00
Jesse Hallam
bb1facb1f5 MM-20755: fix post actions in DMs/GMs (#13248)
* MM-20755: fix post actions in DMs/GMs

The fix for https://github.com/mattermost/mattermost-server/issues/12377 assumed that all channels have teams, but this is false for DMs and GMs.  Test for this and avoid failing on a missing team as such.

Fixes: https://mattermost.atlassian.net/browse/MM-20755

* tweak code for clarity
2019-12-10 12:57:54 -04:00
Jason Frerich
876cf82bad [MM-14725] Inform System Admins when a user who managed bot ac… (#11669)
* Add notification, to sysadmins, when a user is disabled and the user
owns bots.

* If the user doesn't have any bots, there is no need to send a
notifcation to sysadmins

* Remove comment

* Update documention link

* Send as System

* Query teams for each sysadmin and add first response to hardcoded link.

* Remove fmt.print debug statements

* remove link with hard-coded team.  Will add this as future enhancement
Expose GetDisableBotSysadminMessage function so it can be tested
Add test new function for testing new notification feature

* Fix shadow error

* Swap sentences in the message when  System Console > Bot Accounts > Disable bot accounts when owner is deactivated: is set to false

* Another message correction

* Rename Custom Integrations to Integrations

* rename botsDisabled variable to disableBotsSetting

* - increase the number of bots and sysadmins queried to 1000.
- limit the number of bots printed in the post to 10, but mention the
  total bots owned by the user

* Enable translations for sysadmin messages

* - Rename function. The actual purpose for the function is to notify
  sysadmins that a user, that owned bots, was disabled.
- convert GetDisableBotSysadminMessage from a function to a method.
  This allows getting *a.Config().ServiceSettings.DisableBotsWhenOwnerIsDeactivated
  in the method and avoids having to pass the value as an input to a
  function

* fix "make i18n-extract" error.  Reorganize .json file

* Correct the upper range value to be the minimum of number of elements in the
userBots array, or the upper limit (10)

* replace t.fatal with require statements
fix golangci-lint errors

* Create separate message when user managed less than or fewer than 10 bots
Test cases for both message types

* fix i18n sorting

* Using pagination to get the bots and sysadmins instead of setting
arbitrary value for PerPage and only retrieving first page

* only use one translation ID for the message.
push all logic into the template so translators can view the logic
add disableBotsSetting and printAllBots variables to the translation
map

* Break the for loop once len(bots) < perPage value, instead of
breaking once there are no bots. This saves one additional call
2019-12-06 20:00:47 -06:00
Shota Gvinepadze
9898f91f7e [MM-20309] production public key (#13244)
* Add production public key

* Fix unit tests
2019-12-05 23:41:52 +04:00
Mario de Frutos Dieguez
8347f3e1fa Bulk import/export supports direct messages from a user to themselves (#13200)
* Test added to check support for import of messages sent to your own DM
channel

* Support for single member direct channel messages and posts

Now bulk import is able to export/import the self direct channel and
the posts inside

* Improve how the copy of channel members for DM and DM posts

* Improved the tests for the export self-channels
2019-12-05 22:58:38 +08:00
Christopher Poile
6e6a44764c [MM-19892] Fix failing test TestImportBulkImport (#13003)
Automatic Merge
2019-12-04 11:31:52 -05:00
Agniva De Sarker
5a4ac4b249 Fix typo for v5 module path (#13313)
The PR link uses the github repo path, not the module path.
2019-12-04 10:59:11 +01:00
Harrison Healey
4a23d4b282 MM-20681 Fix custom post types not marking channel unread when using Mark as Unread (#13247)
* MM-20681 Fix custom post types not marking channel unread when using Mark as Unread

* Fix inverted if statements
2019-12-03 14:51:50 -05:00
Doug Lauder
420c411595 MM-8607: Add ability to turn off non-critical services when under load; cluster support (#13267)
* MM-8607: Add cluster support for server busy status

MM-8607: Busy.Cluster should be non-exported

MM-8607: rename logging field seconds -> expires_sec

MM-8607: each node clears its own busy flag

MM-8607: ensure unit tests are not sensitive to test machine speed

* MM-8607: chg comment to force CI rebuild
2019-12-03 18:56:39 +01:00
Ibrahim Serdar Acikgoz
4859208744 [MM-19969] - When bulk import finds an already existing post, it should delete existing files (#13037) 2019-12-03 10:52:29 +01:00
Ben Schumacher
d0d6ce0a70 [MM-20353] Change KVSetWithOptions to accept a byte slice (#13213)
* Drop EncodeJSON from PluginKVSetOptions

* Add unit tests for KVSetWithOptions with nil values
2019-12-03 10:46:15 +01:00
Ali Farooq
4e5004ddd2 MM-20642 - Failed to install marketplace plugin on older mattermost servers (#13237)
Automatic Merge
2019-12-02 13:42:54 -05:00
Abhisek Datta
b45e11b28c [MM-19880] Limit size of file inside Zip archive before JSON parsing for Slack Import (#12514)
* Limit size of files inside Zip archive before JSON parsing for Slack import

* Use specific log message when skipping file in Slack import zip due to size

* Updated max size for slack import
2019-12-02 18:55:34 +01:00
Harrison Healey
a0130b86d7 MM-20649 Fix incorrect mention count when marking a DM channel as unread (#13245)
* MM-20649 Fix incorrect mention count when marking a DM channel as unread

* Satisfy govet

* Update missed test
2019-12-02 09:30:08 -05:00
Eli Yukelzon
4e5369e759 MM-19957 - Deactivating a user should increment the Daily and… (#13232)
* corrected active count function
2019-12-02 15:48:36 +02:00
Jesús Espino
a63684fcb5 Consistent license message for all the go files (#13235)
* Consistent license message for all the go files

* Fixing the last set of unconsistencies with the license headers

* Addressing PR review comments

* Fixing busy.go and busy_test.go license header
2019-11-29 12:59:40 +01:00
İlker Göktuğ Öztürk
0adbfa8478 plugin: fix InstallPlugin() API by manually creating RPC code (#13041)
Flugin: fix InstallPlugin() API by manually creating RPC code

previous implementation of InstallPlugin()-#12232 's RPC funcs wasn't working because `io.Reader` isn't supported by the RPC code generation tool.

RPC does not support streaming data and RPC code generation tool does not handle this exception.

thus, RPC funcs are now implemented manually to stream `io.Reader` through a separate multiplexed connection.
2019-11-29 12:41:17 +01:00
Claudio Costa
eeec08c071 [MM-19979] Stop sending new_user websocket event to guests (#13191)
* Stop sending new_user websocket event to guests

* Remove debug msg

* Revert go.mod/go.sum

* Fix linting issues
2019-11-28 14:24:04 +00:00
Miguel de la Cruz
2259b7f2a8 [MM-19948] Set version on module file and internal paths (#13186)
* [MM-19948] Set version on module file and internal paths

* Fixes after merge

* Fix i18n checker error
2019-11-28 14:39:38 +01:00