Commit Graph

1283 Commits

Author SHA1 Message Date
Haardik Dharma
ccc7365ac3 Bump golangci version to v1.38.0 (#17154)
* Update golangci to v1.38.0

Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-28 16:43:41 +02:00
Eli Yukelzon
89281c00b1 MM-35127 CRT: Marking thread as unread doesn't set the timestamp correctly (#17507)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-27 15:48:43 +03:00
Agniva De Sarker
cd4d322e4a MM-32950: Reliable WebSockets: Basic single server (#17406)
* MM-32950: Reliable WebSockets: Basic single server

This PR adds reliable websocket support for a single server.

Below is a brief overview of the three states of a connection:

Normal:
- All messages are routed via web hub.
- Each web conn has a send queue to which it gets pushed.
- A message gets pulled from the queue, and before it
gets written to the wire, it is added to the dead queue.

Disconnect:
- Hub Unregister gets called, where the connection is just
marked as inactive. And new messages keep getting pushed
to the send queue.

If it gets full, the channel is closed and the conn gets removed
from conn index.

Reconnect:
- We query the hub for the connection ID, and get back the
queues.
- We construct a WebConn reusing the old queues, or a fresh one
depending on whether the connection ID was found or not.
- Now there is a tricky bit here which needs to be carefully processed.
On register, we would always send the hello message in the send queue.
But we cannot do that now because the send queue might already have messages.

Therefore, we don't send the hello message from web hub, if we reuse a connection.

Instead, we move that logic to the web conn write pump. We check if
the sequence number is in dead queue, and if it is, then we drain
the dead queue, and start consuming from the active queue.
No hello message is sent here.

But if the message does not exist in the dead queue, and the sequence number
is actually something that should have existed, then we set
a new connction id and clear the dead queue, and send a hello message.
The client, on receiving a new connection id will automatically
set its sequence number to 0, and make the sync API calls to manage
any lost data.

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

```release-note
NONE
```

* gofmt

* Add EnableReliableWebSockets to the client config

* Refactoring isInDeadQueue

* Passing index to drainDeadQueue

* refactoring webconn

* fix pointer

* review comments

* simplify hasMsgLoss

* safety comment

* fix test

* Trigger CI

* Trigger CI

Co-authored-by: Devin Binnie <devin.binnie@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-26 19:51:25 +05:30
Allan Guwatudde
fd546cdff2 [MM-35039] - Send trial ended email (#17478)
* [MM-35039] - Send trial ended email

* Generations

* Use First name with fallback to username

* Use First name with fallback to username for trial ending email
2021-04-23 21:45:47 +03:00
Doug Lauder
ff657bfdef sync profile images (#17375)
support for synchronizing user's profile image for shared channels.
2021-04-22 17:48:09 -04:00
Eli Yukelzon
8c453bbcca MM-34895 CRT: Replying to a root post with an at-mention triggers an unread mention (#17474)
* don't count your own replies as unread

* corrected totalUnreadThreads query
2021-04-22 16:30:43 +03:00
Hossein
a1a8f00957 [MM-34838] Remove Ancillary Permissions That Are Purposefully Being Removed (#17466)
* remove ancillary permissions

* Start writing tests

* Move Ancillary Permissions to FrontEnd

* remove function

* remove test

* clean up

* fix comment

* Update api4/permission.go

Co-authored-by: Martin Kraft <martinkraft@gmail.com>

* Update api4/permission.go

* Update api4/permission.go

* license info

* Add Tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Martin Kraft <martinkraft@gmail.com>
2021-04-21 11:35:47 -04:00
Ibrahim Serdar Acikgoz
28ff4dc8d0 [MM-32281] SqlRoleStore/GetByName: add context to allow read from master (#17176)
* role_store/GetByName: add context

* propagate context in the app layer

* propagate context in the app layer

* add missing import

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-21 18:01:02 +03:00
Chetanya Kandhari
9eceeaa8db Custom status fixes (#17122)
* Changed the request type to POST for the remove recent custom status API

Fixed the custom status clear slash command

* Added Delete method in the remove recent custom status endpoint

* Added one new endpoint to remove recent custom status with POST method

* Added comments for the recent custom status API

Co-authored-by: Manoj <manoj@brightscout.com>
Co-authored-by: Chetanya Kandhari <availchet@gmail.com>
Co-authored-by: Manoj <77336594+manojosh@users.noreply.github.com>
2021-04-21 11:37:17 +03:00
Max Erenberg
f36f5c74b1 Mm 30807 granular data retention scaffold (#17464) 2021-04-20 13:16:40 -04:00
Agniva De Sarker
e0efdd708b Revert "Mm 30807 granular data retention scaffold (#16891)" (#17437)
This reverts commit 3ea75332e7.
2021-04-18 22:41:50 +05:30
Max Erenberg
3ea75332e7 Mm 30807 granular data retention scaffold (#16891)
create the necessary tables, models and APIs for the granular data retention policy feature
2021-04-16 11:32:09 -04:00
Eli Yukelzon
f90209c8a3 MM-34609 Mark-as-unread on a post in a thread should cause auto-follow (#17343)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-16 10:26:08 +03:00
Allan Guwatudde
ab8b8e8bf2 [MM-34240] - Cloud: "Congratulations" welcome email missing images (#17350)
* [MM-34240]-Cloud: Congratulations welcome email missing images

* Use img instead of svg

* Add fallback font Arial

* Feedback impl

* EOF

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-15 13:23:03 +03:00
Maria A Nunez
81c40174e6 Feature: Support Cloud 14-day Trial (#17397)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Nick Misasi <nick.misasi@mattermost.com>
Co-authored-by: Allan Guwatudde <guwats10@gmail.com>
2021-04-14 11:36:36 -04:00
Doug Lauder
f69cb38249 MM-32133 shared channel username collisions (#17347)
Support for handling username collisions between remote clusters. Users belonging to remote clusters have their username changed to include the remote name e.g. wiggin becomes wiggin:mattermost.

@mentions are also modified so the munged username is replaced with the original username when the post is sync'd with the remote the user belongs to.

When adding remote users:
- append the remote name to the username with colon separator
- append the remote name to the email address with colon separator
- store the original username and email address in user props
- when resolving @mentions replace with the stored original username
2021-04-13 10:40:12 -04:00
Max Erenberg
869da7a78b [MM-32044] Reset SAML auth data (#17161)
Automatic Merge
2021-04-13 00:46:30 +02:00
Jesús Espino
35d00b4644 Enable the errorAssertions govet check for mattermost-server code (#17346)
* Enable the errorAssertions govet check for mattermost-server code

* Removing unnecesary change

* Fixing some tests

* Fixing tests

* Fixing more after merge

* Fixing new offending entries

* Fixing small vet checks

* Fixing new cases detected by govet

* Fixing remote_cluster_test errors

* Fixing assertion

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-12 12:51:31 +02:00
Max Erenberg
3a3ec001bf [MM-33826] add more detailed S3 error messages (#17182)
Automatic Merge
2021-04-09 18:16:30 +02:00
Hossein
fef3158bab fix broken test (#17348) 2021-04-06 16:55:20 -04:00
Hossein
daec0b3201 All Sections to SubSections (#16917)
* initial

* Revert "initial"

This reverts commit 3d631aeecd.

* [MM-32352] Add Experimental Subsections BACKEND (#16887)

Automatic Merge

* update appiface

* Fix app layers

* Ancillary Permissions on backend (#17061)

Automatic Merge

* [MM-32799] Add About Section (#17015)

* Add About Section

* add mock key

* Update role.go

* Update role.go

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* [MM-33437] Fix config access tags for experimental settings (#17111)

Automatic Merge

* [MM-32794] Reporting Sub Section (#17035)

* test

* revert

* add permissions

* add new permission stuff

* add store mock

* fix bad merge

* gofmt fix

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* [MM-32343] Environment SubSection (#17054)

* pre-checkout commit

* fix permission for testSiteURL

* pre-merge commit

* increase size of Permissions column in Roles table

* add entry for ENVIRONMENT to testlib/store.go

* use TEXT for Permissions column in Roles table

* use environment subsection permissions for API endpoints

* use subsections permissions for /config/environment

* add suggestions from hahmadia

* update tests to use subsection permissions

* add permissions column back in

* comment out code in upgradeDatabaseToVersion534

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* MM-32351: Add Compliance Subsections (#17023)

* add subsections for compliance sectin

* add to mock functions

* updates for read job

* fixes

* fix test

* update tests

* update tests

* another test fix

* some cleanup

* update mlog

* fix linting

* Fix bad merges

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Hossein <hahmadia@users.noreply.github.com>
Co-authored-by: Hossein Ahmadian-Yazdi <hyazdi1997@gmail.com>

* MM-32347 Site Subsections (#17095)

* Init

* Added migration key in testlib store

* Fix syntax error

* fix bad merge

* fix lint

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* MM-32350 Integrations (#17097)

* implement server subsections

* fix tests

* update test

* go fmt

Co-authored-by: Hossein Ahmadian-Yazdi <hyazdi1997@gmail.com>

* patch forgotten endpoints

* Adding subsection permissions for Authentication (#17087)

* adding new permissions, migrations to do

* permission migrations and ancilary permissions

* running make app-layers

* fixing tests and lint

* adding permissions to saml

* ldap write permissions

* running make app-layers

* fixing conflict

* making app layers

* clean up and fix tests

* change job type

* fix js error, if site url not returned

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Hossein Ahmadian-Yazdi <hyazdi1997@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update permissions_migrations.go

* gofmt

* upgrade to 535

* gofmt

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Max Erenberg <max.erenberg@mattermost.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Anurag Shivarathri <anurag6713@gmail.com>
Co-authored-by: Ben Cooke <benkcooke@gmail.com>
Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
2021-04-06 10:39:48 -04:00
Scott Bishel
2cb82965b0 MM-33905 -always add FeatureFlags to config (#17163)
* always add FeatureFlags to config

* update const to TitleCase

* gofmt

* update method to use 'access:all'

* update method to use 'access:all'

* fix lint

* gofmt

* added comments

* update name of access tag for any

* fix bad save

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-06 10:39:36 -04:00
Agniva De Sarker
db01f2a91b MM-34002: Improve AddUserToChannel (#17174)
* MM-34002: Improve AddUserToChannel

When we would add a user to a channel, we would
check whether the user is removed from that team or not.

During LDAP sync, this check is not required because the
team member would have just been created. Hence, we
pass a boolean flag to bypass the check.

And with that done, we can freely query the replica.

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

```release-note
NONE
```

* Refactor code

* Rename a struct field

* fix double negative
2021-04-02 14:33:23 +05:30
Agniva De Sarker
4f0cfbe329 MM-33913: Fix read-after-write issues with team member (#17173)
During LDAP sync, we would call AddTeamMember which had a read-after-write issue
where we would create a team member but then immediately after that
query the team member.

The same pattern was found in:
AddTeamMember
AddTeamMembers
AddTeamMemberByToken

To fix this, we just return the inserted team member from AddUserToTeam and use that
instead of query GetTeamMember again.

```release-note
NONE
```

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

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-02 13:20:58 +05:30
Doug Lauder
02196e04fa MM-27493 Shared channels (MVP) (#17301)
Remote Cluster Service
- provides ability for multiple Mattermost cluster instances to create a trusted connection with each other and exchange messages
- trusted connections are managed via slash commands (for now)
- facilitates features requiring inter-cluster communication, such as Shared Channels
Shared Channels Service
- provides ability to shared channels between one or more Mattermost cluster instances (using trusted connection)
- sharing/unsharing of channels is managed via slash commands (for now)
2021-04-01 13:44:56 -04:00
Eli Yukelzon
480796a1df MM-33708 - Add MentionCountRoot column to ChannelMembers (#17099)
* added new column for root-only mentions

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-01 14:43:09 +03:00
Allan Guwatudde
489eaa4605 [MM-32639] - Resend user invite emails (#17113)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-31 13:20:53 -04:00
Claudio Costa
ee3f986da0 [MM-32622] Remove app.WaitForChannelMembership() (#17048)
* Remove app.WaitForChannelMembership

* Fix tests

* Fix test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-31 09:40:35 +02:00
Agniva De Sarker
4ba0c09fc7 MM-34389: Reliable websockets: First commit (#17297)
* MM-34389: Reliable websockets: First commit

This is the first commit which makes some basic changes
to get it ready for the actual implementation.

Changes include:
- A config field to conditionally enable it.
- Refactoring the WriteMessage along with setting the deadline
to a separate method.

The basic idea is that the client sends the connection_id
and sequence_number either during the handshake (via query params),
or during challenge_auth (via added parameters in the map).

If the conn_id is empty, then we create a new one and set it.
Otherwise, we get the queues from a connection manager (TBD)
and attach them to WebConn.

```release-note
NONE
```

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

* Incorporate review comments

* Trigger CI

* removing telemetry

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-31 10:05:32 +05:30
catalintomai
ca9f4c9ed8 MM-32882: Add an unread badge/marker to the Main Menu icon and the ‘Plugin Marketplace’ Menu Item (#16992) 2021-03-29 22:55:44 -07:00
Claudio Costa
017e14d4b5 [MM-32822] Improve JobServer state handling (#16959)
Automatic Merge
2021-03-26 10:32:16 +01:00
Claudio Costa
28df047d92 Prevent User.Timezone field to overflow DB column capacity (#17220) 2021-03-25 11:38:43 +01:00
Agniva De Sarker
aba6471512 revertws (#17216)
* Revert "MM-34000: Use non-epoll mode for TLS connections (#17172)"

This reverts commit 2743089b54.

* Revert "MM-33233: Fix double close of webconn pump (#17026)"

This reverts commit 0f98620b65.

* Revert "MM-33836: Detect and upgrade incorrect HTTP version for websocket handshakes (#17142)"

This reverts commit 4c5ea07aff.

* revert i18n

* Revert "MM-21012: Revamp websocket implementation (#16620)"

This reverts commit a246104d04.

* fix go.mod

* Trigger CI
2021-03-24 15:29:23 +05:30
Eli Yukelzon
0cc72342de MM-33544 is_following prop in getPosts API methods (#17093)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-23 13:31:54 +02:00
Mario de Frutos Dieguez
c0971970e9 Revert "Fix initialism errors (PR-3) (#17062)" (#17202)
This reverts commit ea61458f16. This was causing panic in the plugins because the client and the plugin API changed with this PR
2021-03-23 10:32:54 +01:00
Haardik Dharma
ea61458f16 Fix initialism errors (PR-3) (#17062)
* Fix initialism errors

* Revert some changes and regenerate file

* Update client4.go

* Update group_test.go

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-22 22:38:19 +03:00
Max Erenberg
6a77e24adc MM-28090 User settings api when ldap sync (#16822)
Automatic Merge
2021-03-22 19:02:16 +01:00
Agniva De Sarker
2743089b54 MM-34000: Use non-epoll mode for TLS connections (#17172)
* MM-34000: Use non-epoll mode for TLS connections

A *crypto/tls.Conn does not expose the underlying TCP connection
or even a File method to get the underlying file descriptor
like the way a *net/TCPConn does. Therefore the netpoll code would
fail to get the file descriptor.

Relevant issue here: https://github.com/mailru/easygo/issues/3

It is indeed possible to use reflect black magic to get the unexported
member, but I have found unexpected errors during writing to the websocket
by getting the file descriptor this way. I do not want to spend time investigating
this especially since this is already released.

Once this is out, we can decide on the right way to fix this, most probably
by proposing to expose the File method or some other way.

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

```release-note
Fix an issue where websockets wouldn't work with TLS connections.
In that case, we just fall back to the way it works for Windows machines,
which is to use a separate goroutine for reader connection.
```

* Ignore logging errors on non-epoll

On non-epoll systems, we needed to return an error
to break from the loop. But in that case, there is no
need to log the error
2021-03-18 22:27:53 +05:30
Max Erenberg
4699845c0a Mm 29605 read permission s3 bucket (#16977)
Automatic Merge
2021-03-16 15:48:32 +01:00
Agniva De Sarker
4c5ea07aff MM-33836: Detect and upgrade incorrect HTTP version for websocket handshakes (#17142)
Our proxy configuration was historically incorrect, due to which
a lot of customers have that in their setups. As a result, strictly
following the websocket RFC results in a breaking change.

For now, we transparently upgrade the version header to 1.1, if we detect 1.0.
If a client was sending 1.0, it wouldn't have worked anyways because persistent
connections were introduced from 1.1 onwards.

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

```release-note
WebSocket handshakes done with HTTP version lower than 1.1 will result in a warning,
and the server will transparently upgrade the version to 1.1 to comply with the
websocket RFC.

This is done to work around incorrect nginx (and other proxy) configs that do not set
the proxy_http_version directive to 1.1.

This facility will be removed in a future Mattermost version and it is strongly recommended
to fix the proxy configuration to correctly use the websocket protocol.
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-15 23:02:24 +05:30
Ibrahim Serdar Acikgoz
78532699d0 api4/user: add promte/demote uset to local router (#17036) 2021-03-15 18:20:58 +01:00
Jesús Espino
8abb4184b5 Extracting mail service into shared libs (#17030)
* Extracting mail service into shared libs

* Fixing golangci-lint
2021-03-15 11:50:13 +01:00
Martin Raymond Kraft
58dce5930e [MM-31094] Replication Lag (#16888)
* MM-31094: Adds tooling to develop and test using a MySQL instance with replication lag. Adds some lazy lookups to fallback to master if results are not found.

* MM-31094: Removes mysql-read-replica from default docker services.

* MM-31094: Switches (store..SessionStore).Get and (store.TeamStore).GetMember to using context.Context.

* MM-31094: Updates (store.UsersStore).Get to use context.

* MM-31094: Updates (store.PostStore).Get to use context.

* MM-31094: Removes feature flag and config setting.

* MM-31094: Rolls back some master reads.

* MM-31094: Rolls a non-cache read.

* MM-31094: Removes feature flag from the store.

* MM-31094: Removes unused constant and struct field.

* MM-31094: Removes some old feature flag references.

* MM-31094: Fixes some tests.

* MM-31094: App layers fix.

* MM-31094: Fixes mocks.

* MM-31094: Don't reparse flag.

* MM-31094: No reparse.

* MM-31094: Removed unused FeatureFlags field.

* MM-31094: Removes unnecessary feature flags variable declarations.

* MM-31094: Fixes copy-paste error.

* MM-31094: Fixes logical error.

* MM-30194: Removes test method from store.

* Revert "MM-30194: Removes test method from store."

This reverts commit d5a6e8529b.

* MM-31094: Conforming to make's strange syntax.

* MM-31094: Configures helper for read replica with option.

* MM-31094: Adds some missing ctx's.

* MM-31094: WIP

* MM-31094: Updates test names.

* MM-31094: WIP

* MM-31094: Removes unnecessary master reads.

* MM-31094: ID case changes out of scope.

* MM-31094: Removes unused context.

* MM-31094: Switches to a helper. Removes some var naming changes. Fixes a merge error.

* MM-31094: Removes SQLITE db driver ref.

* MM-31094: Layer generate fix.

* MM-31094: Removes unnecessary changes.

* MM-31094: Moves test method.

* MM-31094: Re-add previous fix.

* MM-31094: Removes make command for dev.

* MM-31094: Fix for login.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-12 12:37:30 -05:00
Allan Guwatudde
05720f627b [MM-33198] - Portal: Send admin welcome email after the installation is complete (#17043)
* [MM-33198] - Portal: Send admin welcome email after the installation is complete

* Send cloud welcome email

* Feedback impl-2

* Fix template

* Temp undo

* Update

* make i18n-extract

* Translations

* Feedback impl-3

* More template fixes

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-10 20:39:21 +03:00
Claudio Costa
8612f3a4d1 Fix panic (#17055)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-09 18:05:47 +01:00
Mario de Frutos Dieguez
5203fc8608 [MM-28694] Add MM User information in the CWS request headers (#15824)
* Include user data in the cloud endpoints

Those headers will include the user ID and Email so we can use them
in CWS

* Removed AppError from enterprise/cloud

We're removing the AppError from all the places that don't belong
to the app or api4 packages.

* Remove unused i18n strings

* Move it to the server init of enterprise

Also moved the initialization of the enterprise part in the server after the store is initialized

* Initialize after the store is set in NewServer

The ideal way to do it should be to move the initEnterprise call after
the store is set but that would lead to undesired side-effects so we
initialize the cloud part alone.

Signed-off-by: Mario de Frutos <mario@defrutos.org>
2021-03-05 09:23:39 +01:00
Jesús Espino
633d82f0ac Remove Custom statuses feature flag (#17075) 2021-03-05 10:21:58 +02:00
Jesús Espino
9cc5089af8 Moving mlog to corelibs (#16915)
* Moving mlog to corelibs

* Regenerating app layers

* Fix golangci-lint problem

* Fixing golangci-lint errors

* Renaming from corelibs to shared

* Renaming from corelibs to shared

* Fixing import

* Fixing merge problems

* Fixing build
2021-03-05 09:18:37 +01:00
Eli Yukelzon
4aa6c863c3 MM-30304 - Handle collapsed threads in page apis (#17064) 2021-03-05 09:46:36 +02:00
Eli Yukelzon
c64959b439 MM-31105 /Join <channel name> is case sensitive (#16903)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-03 10:44:18 +02:00