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

1493 Коммитов

Автор SHA1 Сообщение Дата
Christopher Speller
e284b811df Add subresource integrety (#20257) 2022-05-26 10:54:11 -07:00
Ashish Bhate
2315fcf05b MM-43780: Adjust getPostThread API for easier pagination (#20172)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-05-25 18:18:05 -04:00
Michael Kochell
ea5bfe3fd9 Cloud Freemium - Integrations (#20185)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-05-25 12:36:08 -04:00
Nick Misasi
50d069e86d [MM-44307] On Limits Change, archive or restore teams according to the limits (#20247)
Automatic Merge
2022-05-24 16:16:24 +03:00
Miguel de la Cruz
c100fc2135 Revert "config/diff: add utility function to get diffs scoped with struct tags (#20206)" (#20256)
Automatic Merge
2022-05-21 00:16:24 +03:00
Pablo Andrés Vélez Vidal
f08d65909f MM-43529 - start freemium trial (#20163)
* MM-43529 - start freemium trial

* change the method to put

* Add unit testing for the request-trial-endpoint

* use correct require

* add the translation texts

* fix texts

* remove unnecessary log

* change response status code to forbidden when non cloud

Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
2022-05-18 10:19:38 +02:00
Vishal
fd703a365b [MM-43917] Cloud Freemium limits API: messages/posts (#20152)
* WIP - Add api and app funcs

* Add test cases

* Add utils testcases

* Exclude deleted posts

* Add doc for func

* Move api from cloud to usage

* Allow api access to authenticated users

* Change int to int64

* Fix lint issue

* Simplify err check

Co-authored-by: Ashish Bhate <ashish.bhate@mattermost.com>

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Ashish Bhate <ashish.bhate@mattermost.com>
2022-05-17 13:30:40 +02:00
Ibrahim Serdar Acikgoz
8802c6c9d6 config/diff: add utility function to get diffs scoped with struct tags (#20206) 2022-05-16 15:12:12 +03:00
Agniva De Sarker
aa59c28b04 POC: Cross-team recent search (#20027)
Just a quick POC to move fast :P

We use a search pointer to keep track of
the next row to inesrt to. For every new search
we increment the pointer and do modulo 5.
This means that the value will always remain
between 0-4. And that way, we will always overwrite
the oldest entry on every search.

And while getting the results, we get
all results for that user.

The search parameters are json marshalled
and stored as a JSON blob. This is because
there is no need to search/filter them
in the DB.

Pending items:
Tests obviously.

To improve:
The client needs to send the channel ids
instead of channel names.
2022-05-16 13:16:11 +05:30
Agniva De Sarker
6e574aefd0 MM-41569: Prevent compliance directory to be changed on cloud instances (#20198)
https://mattermost.atlassian.net/browse/MM-41659

```release-note
NONE
```
2022-05-13 14:14:26 +05:30
Agniva De Sarker
acae0031d1 MM-44101: GraphQL: Add sidebar categories at the top level (#20178)
Also, add a negate parameter to the team members to get
all sidebarcategories except the default team.

```release-note
NONE
```
2022-05-12 20:03:47 +05:30
Agniva De Sarker
52661807f7 MM-41655: Prevent mmctl import into cloud instances (#20191)
mmctl import is not supported and therefore we stop it.

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

```release-note
NONE
```
2022-05-12 12:37:59 +05:30
Agniva De Sarker
a6d8e45297 MM-44088: Add teamID filter to channelMembers (#20176)
We add 2 new params to channel members query.
1. Filter by teamId.
2. Negate that filter.

We include some more optimizations like:
- Moved the team role checks inside the dataloader.
- Moved the channel pretty name computation inside the loader.

Now that we load less data on initial load, we can reduce
the concurrency requirement to be a bit on the safer side.

```release-note
NONE
```
2022-05-11 13:54:12 +05:30
Nathaniel Allred
6f87eb67fc MM-43084 update product limits through webhook and websocket (#20076)
* Define interfaces for updating subscriptions and product limits from CWS webhook.
2022-05-09 08:05:50 -05:00
Agniva De Sarker
461e407fbe MM-44044: Fix racy TestGraphQLChannelMembers (#20155)
Upgrading the user resolver to dataloader
meant that multiple goroutines would access
the user struct.

Hence we move the user struct sanitization inside
the dataloader itself so prevent access outside
the dataloader.

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

```release-note
NONE
```
2022-05-09 13:19:44 +05:30
Agniva De Sarker
fed5404166 GraphQL: Unlock goroutine throttle to match batch capacity (#20146)
We were throttling the amount of concurrent resolvers
at a given time. The idea behind this was to avoid overloading
the database with too many requests.

However, with the introduction of dataloaders, this limitation
actually becomes a bottleneck because all DB calls are actually
batched, so we are unnecessarily throttling the amount of
items that can be processed in a single batch.

The only caveat with this is that now all resolvers
need to backed by dataloaders, or otherwise not be queried
as part of a loop.

In a subsequent PR, we will be removing channel stats
from under channel to be a top-level object to be returned
for a given channel.

```release-note
NONE
```
2022-05-06 21:53:29 +05:30
Agniva De Sarker
d9e3125e87 MM-42997: Fix flaky TestDeletePostEvent (#20133)
We increase the timeout further. Without this, there is
no reliable way to wait for a message.

Also consolidated the timeout values for other tests.

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

```release-note
NONE
```
2022-05-05 22:05:50 +05:30
Agniva De Sarker
3c83187c5b MM-43929: Ignore archived team memberships in GraphQL (#20130)
https://mattermost.atlassian.net/browse/MM-43929

```release-note
NONE
```
2022-05-04 19:43:02 +05:30
Ibrahim Serdar Acikgoz
a096a99542 [MM-43199] api4/elasticsearch: test elasticsearch after checking the config values (#20078) 2022-04-30 09:50:41 +03:00
Agniva De Sarker
c0eb0fd3c3 MM-43829: Default for user display_name preference (#20087)
We fall back to TeammateNameDisplay if a user display_name
preference is not found. This makes the logic consistent
with other parts of the app.

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

```release-note
NONE
```
2022-04-29 13:36:04 +05:30
Martin Kraft
cb3d8f0a1c MM-41211: Replaces SessionLength*InDays with SessionLength*InHours. (#19838)
* MM-41211: Replaces SessionLength[Web|Mobile|SSO]InDays with SessionLength[Web|Mobile|SSO]InHours.

* MM-41211: Clear the value of the old config settings.
2022-04-28 17:31:35 -04:00
Nick Misasi
373c4655e6 [MM-43337] Updating email templates for trial will end and trial ended emails (#19976)
* Updating email templates for trial will end and trial will end emails

* put back variable

* Rebuilding

* fix tests

* Updates

* [MM-43339] Add Cloud Subscription Upgrade Confirmation Email (#19989)

* Add Cloud Upgrade Confirmation email

* Updates

* String change

* i18n-extract

* Updates

* make email-mocks

* Appease linter

* Add a test

* GMAIL NEVER RENDERS RIGHT

* Important EVERYWHERE because gmail just cant deal

* l

* Last one

* Update image

* Update tests

* Fix tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-28 10:06:16 -04:00
Mylon Suren
52ac449012 [MM-42739] Insights - Top Channels API Endpoint (#19953)
* [MM-42739] Initial setup for top channels for team

* [MM-42739] Add initial tests

* [MM-42739] Update tests

* [MM-42739] Add top channels for user

* [MM-42739] Fix query

* [MM-42739] Update query

* [MM-42739] Improve query performance

* [MM-42739] Remove rank

* [MM-42739] Fix tests to use new time range today

* [MM-42739] Add tests for top channels for user

* [MM-42739] Add test for pagination

* Remove top channels by time struct

* [MM-42739] Update test names

* [MM-42739] Remove rank from top reactions

* [MM-42739] Return empty array instead of nil when result is empty

* [MM-42739] Add additional tests and update permissions check for teams

* [MM-42739] Add excluded channel tests for top reactions

* [MM-42739] Move insights to api4/insights and keep time range as string until required

* [MM-42739] Update queries only check DeleteAt after union

* [MM-42739] Improve query performance by using publicchannels table

* [MM-42739] Fix broken query after merge
2022-04-26 14:42:24 -04:00
Nathaniel Allred
d4db43c95e Mm 43084 add cloud workspace limits endpoint (#20041)
* add cloud workspace limits endpoint
2022-04-22 14:23:19 -05:00
Kyriakos Z
b15cd9d29f MM-41565,MM-42473: fixes incorrect unread thread count (#19962)
* MM-41565,MM-42473: fixes incorrect unread thread count

The infamous "-1 unread threads" bug, was due to incorrectly counting
previous unread mentions and replies.

When we calculate the previous counts, we didn't take into account if
a thread was newly followed one or not. So when a user gets added to a
thread via a mention receives a WS event with the previous count values
calculated by subtracting "1" from the current count values.
In the result the webapp subtracts the previous values for the thread
from the total values of all threads for the user.

This is wrong since the user just followed the thread those previous values
should be 0. Which results into showing a negative value of unread
threads to the user.

This commit fixes this issue by zeroing the previous count values when
the user was not following the thread previously.

* Adds test, and addresses comments

* Changes test's description

* Removes unneeded assertion

* Empty commit just to re-build
2022-04-15 12:47:04 -04:00
Agniva De Sarker
ed3b3b57de MM-42877: Fix TestGetFileHeaders (#20002)
The issue seems to be that different distros
have different set of included mime types
built-in. Go looks into those directories
and it looks like our CI systems don't have
those files.

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

```release-note
NONE
```
2022-04-15 14:49:48 +05:30
Kyriakos Z
79e36d4596 [MM-41185]: new API to mark thread as unread (#19951)
* [MM-41185]: new API to mark thread as unread

Until now we mark a thread as read/unread by sending a timestamp to the
server. This created some issues when marking a thread as unread from a
post. We needed to send the post.create_at - 1 as a timestamp but we
didn't do so consistently.

This commit adds a new API to set a thread as unread by post id.
Making all clients agnostic of the timestamp, and thus solving consistency issues.

Endpoint: /api/v4/users/{user_id}/teams/{team_id}/threads/{thread_id}/set_unread/{post_id}

* Updates client.go adding SetThreadUnreadByPostId

* Guards endpoint behind read channel permission

* Returns status 400 if post_id not belong in thread

* Root post as post_id should be permitted
2022-04-15 10:55:47 +03:00
Mylon Suren
99f02fe96e [MM-42742] Add top reactions endpoint (#19850) 2022-04-14 13:09:35 -04:00
Agniva De Sarker
c0b2aae84e MM-43340: Fix racy test TestGraphQLChannelMembers (#19968)
We take a shallow copy of the team pointer before
we pass that to the other functions.

This is because the resolvers run in separate
goroutines.

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

```release-note
NONE
```
2022-04-13 18:50:33 +05:30
Michel Engelen
ca8aea9a06 [MM-41993]: fixed counting thread mentions in unread root post (#19874)
* removed appending the root post to the posts list

also changed `UpdateAt` to `CreateAt` in thread_store.go in accordance with kyriakos

* fixed failing test after latest change

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-11 12:43:14 -04:00
Agniva De Sarker
7f0d1cf0dd MM-43144: Add teams loader (#19960)
```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-11 20:51:33 +05:30
Agniva De Sarker
16b1cbd6e3 spelling (#19956)
* spelling: activated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: attachments

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: categories

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: category

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: cellspacing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: channel

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compliance

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: constraint

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: counts

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: createat

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: deactivate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: destination

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exceeded

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: failed

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: foreign

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: hours

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inactivity

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inappropriate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: management

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: mismatch

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: recipients

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: scheme

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: signature

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: subscription

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: suggestions

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: sync

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: telemetry

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: webhook

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* Trigger CI
```release-note
NONE
```

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-11 19:31:19 +05:30
Agniva De Sarker
d1de4857aa MM-43145: channels loader (#19957)
Add channels dataloader

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

```release-note
NONE
```
2022-04-11 13:41:09 +05:30
Pablo Andrés Vélez Vidal
4b354685e9 MM-39058 - invite people to join team and channels (#19849)
* MM-39058-invite-to-team-from-add-channel

* fix tests by validating the memberInvite is not nil

* fix i18n texts

* fix lint problem

* fix translation lines

* fix the data structure

* modify api4-team_local file to match with the expected structure

* fix unit tests, fix translation tests

* remove go routine cause not necesary

* add unit test for invite to team and channel

* remove unnecessary validation

* allow both data structures, simple string array and object with memberInvite struct

* fix texts

* fix linter

* fix problems with graceful invites workflow

* handle error while parsing body

* fix unit tests

* take the address just once

* rename channels to channelIds

* fix unit tests

* add tests and fix local channels invite support

Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
2022-04-08 12:20:44 -05:00
Agniva De Sarker
56dfcddff5 MM-43143: Dataloaders for roles (#19936)
We use a dataloader to optimize roles loading.

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

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-08 15:32:35 +05:30
mkraft
ce2646de3e Disambiguates some units. (#19875)
* Disambiguates some units.

* Updates DB attribute.

* Updates some more error-prone units.

* Updates some tests with legible constants.

* Updates query for MySQL case sensitivity.

* Fixes more casing issues.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-07 13:58:40 -04:00
Ashish Bhate
d40d216b57 [MM-43073] broadcast post unread websocket when CRT off (#19927)
* [MM-43073] broadcast post unread websocket with CRT off

* clean up debug

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-06 16:42:31 -04:00
Agniva De Sarker
5fee97c51c MM-41323: Secure plugin marketplace modification (#19889)
We disable plugin marketplace modification if plugin uploads
are disabled

https://mattermost.atlassian.net/browse/MM-41323
```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-06 15:29:51 +05:30
Agniva De Sarker
ec91ca46ff MM-42813: Fallback to default config if nil is passed (#19920)
https://mattermost.atlassian.net/browse/MM-42813

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-06 08:30:16 +05:30
Nick Misasi
650ad3b3ae [MM-42822] Check for and return HTTP 451 for all trial requests (#19873)
* Check for and return HTTP 451 for all trial requests

* Use constant in another spot too

* add a test

* Update test name
2022-04-04 09:48:14 -04:00
Ashish Bhate
9521797b15 MM-40148: threadsOnly query param for user threads (#19833)
* MM-40148: threadsOnly query param for user threads

Currently we always calculate counts when fetching user threads.
Those counts include total, unread replies, and unread mentions,
and are potentially expensive to calculate.

This commit adds a new query param 'threadsOnly' which won't calculate
any counts and just return threads.

Co-authored-by: koox00 <3829551+koox00@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-04 17:50:13 +05:30
Ibrahim Serdar Acikgoz
7b8a2e89d4 api4/system: add check if model.FileSettings is empty (#19876)
* api4/system: add config validation for model.FileSettings

* reflect review comments

* add unmarshal
2022-04-04 15:03:31 +03:00
Ibrahim Serdar Acikgoz
7ab6ea2bad api4/post_test: skip TestDeletePostEvent (#19892) 2022-04-04 14:54:51 +03:00
Agniva De Sarker
1cc50ff90c api4/license: Return 400 instead of 501 if format is not passed (#19856)
```release-note
NONE
```


Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-04 10:27:29 +05:30
Allan Guwatudde
fa56ee9d9a [MM-42713] - Remove cloud user limit restrictions (#19835)
* [MM-42713] - Remove cloud user limit restrictions

* remove unused code

* fix translations

* feedback impl-1

* enterprise code clean up

* feedback impl-2

* fix mocks

* fix translations

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-31 18:24:38 +03:00
Agniva De Sarker
9adf06e122 MM-42092: Add better debugging for TestDeleteChannel (#19872)
When the test fails, it is not clear whether the method
returned an error or it returned a channel with DeleteAt
set to 0. The if condition was also incorrect because
if the error was not-nil the condition would evaluate
to true and the test would pass.

We split the condition into 2 separate cases which will
let us know exactly what is failing.

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

```release-note
NONE
```
2022-03-31 10:43:41 +05:30
Ibrahim Serdar Acikgoz
3cab0f1d8d [MM-42339] api4/license: add a nil check to not panic if server is not EE dist (#19770)
* api4/license: add a nil check to not panic if server is not EE dist

* add a test case
2022-03-30 19:09:57 +03:00
Agniva De Sarker
5db226b2f0 MM-42652: Skip Flaky test in CreateCategoryForTeamForUser (#19857)
https://mattermost.atlassian.net/browse/MM-42652

```release-note
NONE
```
2022-03-29 19:36:50 +05:30
Julien Tant
0babc01749 [MM-41998] Channel Info RHS: display number of files for a channel (#19822)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-25 13:28:14 -07:00
Ibrahim Serdar Acikgoz
3e8b81c0c7 graphql: Add channel stats under channel (#19804)
* graphql: Add channel stats under channel

* add permission check
2022-03-25 11:59:57 +03:00