Commit Graph

1002 Commits

Author SHA1 Message Date
Jesús Espino
e0edd2bebb Add trial license api (#14603)
* Initial request trial api creation

* Adding test license public certificate

* Adding go client method

* Applying changes to use production environment

* Removing accidentally added strings

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-02 21:34:15 +02:00
Rodrigo Villablanca
52cf817c8e SqlTermsOfService migrates to plain errors (#14675)
* Advances migragint TermsOfService

* Advances...

* Replaced message key

* Replaced message key

* Replaced message key

* Replaced message key

* Refactor name of errors

* Fix mixed type of error

* Fix-imports

* i18n-extract

* Rollback changes

* Rollback changes

* Rollback changes

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-02 22:47:52 +05:30
Rodrigo Villablanca
85a69d6112 Migrate Get/GetFromMaster methods from ChannelStore to return error interface (#14688)
* Advances

* Migration finished

* Rename err to normalized error

* fix imports

* Renamed key

* Renamed key

* Suggestions

* Fix i18n

* Fix tests

Co-authored-by: Jesús Espino <jespinog@gmail.com>
Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2020-06-02 21:58:29 +05:30
Siyuan Liu
6a5dd550c8 migrate direct usage of lru to cache2 (#14508)
Automatic Merge
2020-06-02 06:01:30 -07:00
Ashish Bhate
8d4da8b968 MM-25073/MM-25074: local mode for getGroupsByChannel and getGroupsByTeam (#14668)
* local mode for getGroupsByChannel

* local mode for getGroupsByTeam
2020-06-01 12:01:05 +02:00
Eli Yukelzon
2af00f73c0 MM-24847 MM-24484 MM-24850 MM-24849 - local mode for commands (#14571)
* 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

* Mark the request as errored if it's local and the origin is remote

* Set the socket permissions to read/write when initialising

* Fix linter

* Replace RemoteAddr check to ditch connections with the IP:PORT shape

* added update/move/get/delete command in local mode

* merge fix

* .

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
2020-05-31 16:57:04 +02:00
Martin Kraft
c529d5190a MM-25040: Restrict associated groups to channels when team is group-constrained. (#14619)
* MM-25040: Only return team-associated groups if the team is group-constrained.
MM-25040: Prevents associating a group to a channel if the team doesn't have the group first.

* MM-25040: Fix lints.

* MM-25040: Still add the groupteam if the team is not group-constrained.

* MM-25040: Wraps groupteam upsert in else branch for efficiency.

* MM-25040: Removes unnecessary page iteration.

* MM-25040: Fix typo.

* MM-25040: Moves filtering to SQL.

* MM-25040: Updates tests, check pagination.

* MM-25040: Fix lint error.

* MM-25040: Adds some more group store tests.

* MM-25040: Fix for wrong test parameter.
2020-05-29 10:46:52 -04:00
Eli Yukelzon
553af3a694 MM-24597 Migrate API handler deleteChannel to be compatible with local mode (#14532)
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-27 16:24:44 +03:00
Agniva De Sarker
14f7118dde MM-22706: pass along set_online flag in websocket response (#14591)
* MM-22706: pass along set_online flag in websocket response

To let the client know whether a user has created a post without
being online or not, we get the set_online query param and
pass it down to the websocket event being passed down to the client.

With this PR, the "data" field of the `posted` event will contain
a `set_online` boolean field set to true/false depending on the
query_param set_online value set in the createPost call.

* Setting to false for auto responder

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-27 17:35:02 +05:30
Eli Yukelzon
b9309b2af1 MM-24595 Migrate API handler getChannelMember(s) to be compatible with local mode (#14533)
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-27 14:58:39 +03:00
Scott Bishel
ebece6c23a MM-25014 - Default Group Name to null, until AllowGroupReference is set (#14651)
* make Group.Name a pointer to allow null

* fix unit tests

* fix build error

* fix unit test

* ensure Name field not nil

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-26 19:21:29 -06:00
Arianna Vespri
2135096d88 Convert bool string comparisons to strconv.ParseBool for REST parameters (#13650)
* Convert bool string comparisons to strconv.ParseBool for REST parameters

* Log failed bool conversions

* Rename errors, changed log levels

* drop strconv.ParseBool error handling

If the query string parameter is omitted, strconv.ParseBool returns an error for the empty strings, which spams the logs. Instead, just assume the default semantics of a `false` return value if an error occurs.

* allow randomized Client4 booleans

It's hard to test api4's handling of the various boolean input values
accepted. Extend Client4 with support for overriding how it builds those
strings, and pick a random value on test startup.

* gofmt -s

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2020-05-24 05:01:31 +08:00
Ben Schumacher
23ecc9ad0a [MM-25284] Include license type in Marketplace request (#14586) 2020-05-23 07:05:51 +02:00
Ashish Bhate
33bfebc797 MM-24845/MM-24846: local mode handler for createCommand and listCommands (#14486)
* Add local mode handler for createCommand
* Add local mode handler for listCommands
* Fix bad merge

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-22 17:18:22 +05:30
Ashish Bhate
ea86dc9a62 MM-24872/MM-24873: local mode support for addTeamMember and removeTeamMember (#14534)
* Add local mode handler for addTeamMember

* Add local mode handler for remoteTeamMember

* short circuit session team permission for local mode

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
2020-05-22 15:52:57 +05:30
Gabe Jackson
f52211afcf Remove database read check from enhanced ping endpoint (#14625)
The enhanced ping endpoint can return an unhealthy database read
result if the database read replicas have a high-enough replication
delay. Instead of adding the complexity and delay of retry logic,
we are opting to remove the read check for now and will re-add it
in the future in a separate health check flow.
2020-05-21 16:29:21 -04:00
Shota Gvinepadze
43e606173b [MM-20684] Slash Command Autocomplete (#14557)
* [MM-20684] Initial implementation of the Command Autocomplete (#13602)

* Implement Autocomplete Data

* Change CommandName to Trigger

* Fix Autocomplete test

* Make stylistic changes

* Rename a bunch of fields and methods

* Fix variable names, safer type assertions

* [MM-20684] plugin autocomplete implementation (#14259)

* Add an endpoint for command autocomplete suggestions

* Add full Suggestion to the AutocompleteSugestion struct

* Add Dynamic Argument support

* Tidy up things

* Fix missed test case

* Add support of the named arguments

* Update autocomplete API

Fix review issues

Implement dynamic args as a local request

* Fix ineffassign

* Add support of the uppercase letters in arguments

* Add support of the optional arguments

* Remove ineffectual assignment

* Add support for icons (#14489)

* Address couple of nits

* Add comment to IconData

* Add types to all consts

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-21 12:24:56 +04:00
Agniva De Sarker
15ed9a8f20 MM-25006: Fix occurences of unclosed http bodies (#14521)
* MM-25006: Fix occurences of unclosed http bodies

And while here, we also use ioutil.Discard to read the remaining
body instead of reading with ioutil.ReadAll which allocates a separate
byte buffer.

* Fix mistake

* Address review comments

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-20 08:41:37 +05:30
Miguel de la Cruz
0154b8059b [MM-20979] Add first implementation of the Bleve search engine (#14562)
* [MM-20979] Add first implementation of the Bleve search engine

* Fix i18n

* Migrate searchengine utils tests

* Fix linter

* Don't add allTermsQ if both termQueries and notTermQueries are empty

* Fix test that should work if user is system admin

* Modify naming according to review comments

* Abstract getIndexDir function

* Extracting bleve engine name as a constant

* Merge both Indexer interfaces into one

* Add worker stopped message

* Allow worker to be started/stopped with config change

* Use constants for index names

* Modify test order

* Fix linter

* Trying to unlock the CI
2020-05-20 01:29:55 +02:00
Miguel de la Cruz
0d89ff5d0e Mm 23710 mmctl local mode (#14561)
* [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

* [MM-24401] Base approach for Local Mode (#14333)

* 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

* 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

* Mark the request as errored if it's local and the origin is remote

* Set the socket permissions to read/write when initialising

* Fix linter

* Replace RemoteAddr check to ditch connections with the IP:PORT shape

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

* Fix translations order

* [MM-24832] Migrate plugin endpoints to local mode (#14543)

* [MM-24832] Migrate plugin endpoints to local mode

* Fix client reference in helper

* [MM-24776] Migrate config endpoints to local mode (#14544)

* [MM-24776] Migrate get config endpoint to local mode

* [MM-24777] Migrate update config endpoint to local mode

* Fix update config to bypass RestrictSystemAdmin flag

* Add patchConfig endpoint

* MM-24774/MM-24755: local mode for addLicense and removeLicense (#14491)

Automatic Merge

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Ashish Bhate <bhate.ashish@gmail.com>
2020-05-19 18:20:41 +02:00
Martin Kraft
d7cb890f34 MM-25095: Handles static JS and CSS using Brotli encoding. (#14524)
* MM-25095: Handles static JS and CSS files using Brotli.

* MM-25095: Linting fix.

* MM-25095: Adds missing license.

* MM-25095: Moves initialization of slice.

* MM-25095: Moves initialization of slice.
2020-05-19 08:40:13 -04:00
George Goldberg
6ae9513474 MM-24176: Regenerate invite ID on team privacy change. (#14529)
* MM-24176: Regenerate invite ID on team privacy change.

* Fix the other place this setting can be changed.

* Fix tests.

* Satisfy the tyrannical golangci-lint.
2020-05-19 12:04:51 +01:00
catalintomai
6dc8eccc13 MM-23395: Add websockets support for update group (#14202)
* MM-23395: add websockets support for update group
2020-05-18 09:43:26 -07:00
Agniva De Sarker
21af1f49f1 MM-25238: Fix system ping check to read from master (#14580)
The code was writing to master and immediately after that reading
from a replica causing it to fail intermittently.

Since this is not a very high-traffic table, it should be safe to read
from master always.
2020-05-15 14:19:46 +05:30
Agniva De Sarker
729a84a3e6 MM-24135: Migrate AppError from SaveChannel/channel_store.go (#14299)
* MM-24135: Migrate AppError from SaveChannel/channel_store.go

This is the first POC of migration of store app errors to plain error.

We create a few basic error types in the store package and use
them to return the errors from store methods. In the app layer,
we inspect the error and re-create the exact app errors. This lets
us preserve the same error content, but yet move to plain errors.

Since this is a gradual migration, this means that the error inspection
code will be duplicated across the app layer whenever a store method
is invoked. But all of that should go away once we start propagating
the errors higher up the hierarchy.

There have been a significant amount of changes in the storetest and searchtest
layer, primarily because we have to rename the err variable now that it is of
a different type.

* Addressed review comments

* Made all appError origins to be CreateChannel

* Remove typed internal error

* Fix translations

* fix layer generation

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-12 21:23:41 +05:30
catalintomai
41e58d9769 MM-23816: Group Mentions: Add ability to rename group names (#14338)
* MM-23816: Group Mentions: Add ability to rename group names
2020-05-12 08:35:03 -07:00
Martin Kraft
3f6c9ab40c Adds server awareness. (#14271)
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-11 11:45:54 -04:00
Agniva De Sarker
2e1dc79a03 Remove concurrent write to websocket connection (#14527)
This test writes directly to a connection
which causes panics and more frustration in an already fragile CI.

Since this anyways checks an edge condition, and will anyways be
removed in v6, let's remove this for now and let CI be happy.
2020-05-11 13:19:00 +05:30
Agniva De Sarker
48256721c4 MM-24611: Fix flaky test TestDeletePreferencesWebsocket (#14399)
After registering the conn in the hub, we proceeded to send a
direct message to the user. We had changed it to send the direct message
in the same hub goroutine that handles the registration. This was the correct
behavior and fixes chances of having panics due to sending to closed channels.

However, often fixing something unearths some deeper underlying bug. This was
such a case :)

The issue was that register channel had a buffer size of 1. And we were sending
a direct message after registration. In the code to send direct message, we
were checking if the user has been registered or not, and if not, then skip it.

Therefore, since the register channel buffer was 1, it could very well be that
the select case would pick up the direct message send case first - in which
case it would not have been registered, and therefore no hello message would be sent.

The fix is to unbuffer the register and unregister channels. There does not seem
to be a valid reason to make these buffered channels. They are meant to be
synchronous operations, because the code following them assumes that the user
has been registered.

While here, we also remove all the time.Sleeps before waiting on the Response channel
because they are not required at all. Waiting on a channel is already blocking.

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2020-05-09 08:45:03 +05:30
Scott Bishel
80c846412d MM-24692: Add a since parameter to getGroups api (#14444)
* add a since parameter to getGroups api

* update for lint error

* when using since, return deleted groups as well.

* update flaky test, groups have same create time

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-07 14:35:09 -06:00
Scott Bishel
bdd0e9febb MM-24694: Add getGroupsByUserId to API layer (#14443)
* add getGroupsByUserId to API layer

* update for lint errors

* add check for contextId = userId or ManageSystem Permission

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-07 13:35:56 -06:00
Shibasis Patel
882b0324b5 MM_22682_Centralize_ID_Validation (#14237)
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-07 13:27:35 -04:00
Doug Lauder
5e59b5f70c MM-23935 extend session expiry on user activity (#14275)
* MM-23935  extend session expiry on user activity

- if user types anything before a session expires the session will be extended to now + session length

- ensures new session expiries are not written to DB too frequently

- new session store func for updating session ExpiresAt

- session length defaults for mobile and web/ldap changed from 180 days to 30 days
2020-05-06 15:41:10 -04:00
Gabe Jackson
22c949618c Fix API ping endpoint race condition (#14365)
This corrects an issue found when running multiple clustered
Mattermost servers and using the optional `get_server_status`
check on the ping API endpoint. This is done by allowing each
server to write and read from its own health check key in the
system table.
2020-05-05 22:44:18 +08:00
Jesús Espino
224b72c61e MM-24037 Adding getKnowUsers API endpoint (#14332)
* Adding getKnowUsers API endpoint

* Adding i18n strings

* Fixing golint errors

* Adding doc strings

* Remove debug line

* Updating app_iface

* Fixing gofmt
2020-04-28 12:52:43 +02:00
Nev Angelova
6362926b5c [MM-23827] - Update nps plugin version (#14369)
Co-authored-by: Nevyana Angelova <nevyangelova@Nevyanas-MBP.fritz.box>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-04-28 10:54:07 +02:00
Farhan Munshi
036f9384b4 [MM-23264] Get channel member counts by group (#14068)
* MM-23264 Add api endpoint for get groups with members in channel

Add store tests

Add tests for api func

Gofmt

Apply changes from code review

* MM-23264 Make store layers

* MM-23264 Check read permission on channel member counts

* Trigger CI
2020-04-24 17:12:54 -04:00
Attila Molnar
f77ad4992b Fix assertExpectedWebsocketEvent ignoring the passed event (#14330) 2020-04-21 11:11:25 +02:00
Doug Lauder
26310720be MM-23724 add RestoreTeam endpoint (#14297)
* MM-23724 add RestoreTeam endpoint
* assert added to unit test
2020-04-20 22:40:22 -04:00
Doug Lauder
98c6401f54 MM-23722 add endpoint for modify team privacy (#14287)
* MM-23722 add Rest API for updating team privacy
* unit tests for UpdateTeamPrivacy
2020-04-20 21:09:40 -04:00
Mario de Frutos Dieguez
cff7de9e68 [MM-24065] Guest users should be able to search by channel (#14302)
* Remove unnecessary check for PERMISSION_LIST_TEAM_CHANNELS

In the autocompleteChannelsForTeamForSearch method we're checking for
the PERMISSION_LIST_TEAM_CHANNELS permission in order to avoid filtering
channels in the autocomplete search but this check is not necessary.

Now we're going directly to the database to search for those channels
in this specific method and we're filtering by channel membership and
team so there is no chance that we are going to filter undesired
channels to the user.

[Here](https://github.com/mattermost/mattermost-server/blob/v5.22.0/store/sqlstore/channel_store.go#L2014)
is the query where you can see the filtering we're making
2020-04-20 11:21:51 +02:00
catalintomai
b90f4f46e2 MM-23015: Enable or disable group mentions (#14010)
* MM-23015: Enable or disable group mentions + show them in suggestion list


Co-authored-by: Catalin Tomai <catalin.tomai@mattermost.com>
2020-04-13 11:37:29 -07:00
Doug Lauder
6a27ed4a1d MM-22785 audit server CLI (#14144)
Add auditing to server CLI.

Also:
- simplify auditing in API layer
- reduce number of AddMeta calls
- have models serialize themselves
- more consistent field naming
2020-04-08 00:52:30 -04:00
Doug Lauder
e2d1af17de MM-23489 Fix poor Unicode handling in display names (#14214)
Filter blacklisted Unicode characters from:

user: first name, last name, nickname, bot description, username
team: name, display name, description, company name
channel: name, display name
2020-04-07 16:56:07 -04:00
Agniva De Sarker
4210ae60ab MM-22056: Fix flaky test TestUploadFiles (#14234)
Automatic Merge
2020-04-07 07:09:04 -07:00
Eli Yukelzon
92380d83fc OpenAPI Mattermost Go Vet integration (#14216)
* integrating govet
* added api spec check to CI
2020-04-07 16:18:08 +03:00
Martin Kraft
f92d3fa518 MM-23876: Fix for patching channel moderations with a null team schem… (#14239)
* MM-23876: Fix for patching channel moderations with a null team scheme channel guest role.

* MM-23876: Tests the moderations response.
2020-04-07 17:35:03 +05:30
Martin Kraft
19cf3e85b7 MM-23770: Fix for blank DefaultChannelGuestRole on team schemes. (#14210)
* MM-23770: Fix for blank DefaultChannelGuestRole on team schemes.

* MM-23770: Adds test for an team scheme with a blank DefaultChannelGuestRole field.

* MM-23770: Fix for unexpected Schemes.Get.
2020-04-02 08:09:23 -04:00
Eli Yukelzon
52c92d6659 MM-23185 - Markdown image hosted by plugins are not shown if l… (#14185)
* avoid image proxy for local images

* added test for local images
2020-04-01 11:45:26 +03:00
Fedor Vitkovskiy
896c3f736d MM-23484 - add simple validation to getUserStatusesByIds (#14158)
* MM-23484 - add simple validation to GetUsersStatusesByIds

* MM-23484 - return early in validation, add extra test case

* MM-23484 - add test case for empty array

Co-authored-by: Fedor Vitkovskiy <fedorvitkovskiy@pop-os.localdomain>
2020-03-31 20:28:26 +02:00