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

1515 Коммитов

Автор SHA1 Сообщение Дата
Barış
ccab5be6c4 Mm-20223 Add webp emoji support (#20283)
* Added webp package into app/emoji.go , also added a test

* fixed import order inside emoji.go

* Ran go mod tidy

* Conversion to png for Webp emojis that must be resized is implemented

* Deleted unused import

* Added reading mechanism for webp instead of creating

* fileutils and filepath are used while reading a webp file during test

* Deleted readtestwebp function and put it in emoji_test as requested

* Added webp image upload test inside api4/file_test.go

* Expect image is changed from false to true

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-21 10:08:02 +05:30
Pablo Andrés Vélez Vidal
2b8d63b606 MM-44509 - subscription change not reflected after trial (#20352)
* MM-44509 - subscription change not reflected after trial

* fix the tests

* receive the subscription id as param, defer the cache invalidation

* validate business email with body request

* update api request to accept json body payload

* fix unit tests

* fix tests after merge conflict fixes

Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-21 01:40:27 +02:00
Shivashis Padhi
2cd83d2f8d [MM-44084] Feature: Top threads insights (#20195)
* Add route endpoints, model, store functions, and tests for top threads

* Run make store-layers

* Make the following changes

 - Fix top user threads query
 - Fix passing parameters in api4/insights.go to handler in app
 - Add top user threads test

* Add post-message, user_id, participants information to insights results

* model.TopThread.UserID -> model.TopThread.UserId, for compatibility with MySQL

* Rename name -> channel_name

* Add user information to response

* Link post in response, filter out deleted root posts from top threads

* Handle thread delete cases, add app tests for threads insights

* lint: fix typo

* lint: rename asserts

* lint: require.nil -> require.NoError

* Add integration tests for thread insights

* Add embeds and images to top posts

* Add license checks for top threads endpoints

* Query users in batch to populate post-creator

* Make the following changes

 - Add license to test server in api4/
 - Add tests for threads insights
    - top team threads shouldn't include threads from other teams, DMs
    - Test duration constraint
    - Pagination testing for top threads in model/insights_test.go

* Add i18n-extract

* i18n fixes

* Add username, nickname to user_information

* Hide message, user_id, post_id, reply_count in depth=1 of top threads response

* Fix tests using response.reply_count to use response.post.reply_count

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-20 10:27:17 -04:00
Nathaniel Allred
d43c06ea75 remove freemium feature flag (#20491) 2022-06-17 11:13:22 -05:00
Riccardo Santoni
dd7067cbe9 [MM-44434] Introduced search for channel id's through system console. (#20259)
* Introduced search for channel id's

* Small fix to test case as it is not looking at count

* Introduced searching channels by id as a ChannelOpt. Defaulting to true for system console for the time being

* go fmt

* Modified whether to include search by id by passing it in as prop to search endpoint. Modified webapp to pass through search by id as well

* Fixed issue with full text search, as there is not always necessarily an index on Id.

* Modified test to verify count, and moved code inside conditional

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-16 11:32:16 -04:00
Martin Kraft
182ae1234a MM-43956: Adds post counts by duration. (#20131)
* MM-43956: Adds post counts by day.

* MM-43956: Test data cleanup. Switch from Unix to UnixMilli.

* MM-43956: Changes from selecting date data types to strings in SQL.

* MM-43956: Fixes date format key.

* MM-43956: Adds missing user id scope for 'my' top channels graph.

* MM-43956: Adds the ability to group post counts by hour.

* MM-43956: Require enterprise or professional license. Reject guests.

* MM-43956: Adds license for tests.

* MM-43956: Renames function.

* MM-43956: Omits future hours from post counts by hour.

* MM-43956: Adjust API response grouping to users timezone.

* MM-43956: Adds translation.

* MM-43956: Adds user's timezone to the data tier for the grouping by day and hour.

* MM-43956: Fixes layers.

* MM-43956: Lint fix.

* MM-43956: Fix store layers.

* MM-43956: Switches to default name for time package; changes parameter names to avoid naming conflict.

* MM-43956: Updates mocks.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-13 16:22:34 -04:00
Agniva De Sarker
4b8cb4e272 MM-44806: Avoid pointers in JSON parsing in updateCategoryForTeamForUser (#20431)
Passing null is a valid JSON input for a pointer struct. So we avoid
passing pointer to pointer.

https://mattermost.atlassian.net/browse/MM-44806
```release-note
NONE
```
2022-06-11 00:24:23 +05:30
Agniva De Sarker
b443746e80 MM-44805: Avoid pointers in JSON parsing in createCategoryForTeamForUser (#20429)
Passing null is a valid JSON input for a pointer struct. So we avoid
passing pointer to pointer.

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

```release-note
NONE
```
2022-06-11 00:24:04 +05:30
Michael Kochell
e18b1cf89f Check for cloud license and CWS error when checking integration freemium limits (#20387)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-09 15:57:02 -04:00
Ben Cooke
2c63e8dd08 [MM-43785] Hide insights feature intro for new users (#20214)
* tools updates

* Revert "tools updates"

This reverts commit 6293297b55803c5a263e200ebd80192899666ae9.

* hide insights modal by default for new users

* updating feature flag for test

* updating preference tests

* fixing lint

* fixing comment

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-08 14:56:34 -04:00
Kyriakos Z
5396c530bf MM-42581: fixes unread threads on user channel add (#20181)
* MM-42581: fixes unread threads on user channel add

Currently when we are adding a user to a channel we don't send previous
values for unread replies and mentions. This is resulting the thread to
not be marked as unread in the UI, since we rely on the previous values
for that.

This commit fixes the issue by returning previous unread values of 0.

* Adds test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-08 14:01:58 -04:00
Ibrahim Serdar Acikgoz
c986693e4a Revert "config/diff: add utility function to get diffs scoped with struct tags (#20297)" (#20391)
This reverts commit a18934b042.
2022-06-08 17:28:35 +03:00
Vishal
27fc14201f [MM-42192] Include deleted posts in GetPost (#20358)
* Introduced include_deleted query param on get posts endpoint

* Update the correct func name in the comment.

Co-authored-by: santoniriccardo <santoni.riccardo@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-06 13:29:42 +05:30
Michael Kochell
7833e595aa [MM-44604] Ensure we return after setting error in api4/config.go (#20294) 2022-06-03 10:14:56 -04:00
Ashish Bhate
8f912b697e MM-43918: freemium limit for storage (#20225)
Summary
Adds an API end point to return storage usage

Ticket Link
https://mattermost.atlassian.net/browse/MM-43918
2022-06-03 11:48:29 +05:30
Nick Misasi
f42702e13e Add StatusOK return to the softDeleteTeamsExcept controller (#20340)
* Prevent cloud limited installations from restoring teams when at or above the teams limit

* Code clean up

* fix i18n

* Actually fix i18n

* updates for govet

* Update model/client4.go

Co-authored-by: Vishal <vish9812@gmail.com>

* [MM-44397] Restrict team creation based on subscription limits (#20282)

* restrict team creation based on limits

* Update api4/team.go

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* Fix tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* Add additional field to teamsusage

* Fix

* remove useless test

* Fix error for team creation

* Remove apostrophe

* Add ReturnStatusOK to softDeleteTeamsExcept

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Vishal <vish9812@gmail.com>
Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>
2022-06-02 09:02:41 -04:00
Pablo Andrés Vélez Vidal
d5333603ab MM 43666 - request bussiness email (#20315)
* MM-43666 - request bussiness email

* add the newValidEmail information

* revert ff model changes

* remove unnecessary pointer and fix test spelling

* fix unit tests and add a new one for when passing a valid email

* fix go lint

Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-01 23:36:03 +02:00
Ibrahim Serdar Acikgoz
fe3816cc20 store: guests will only receive results of which channels they are in (#20295)
* store: guests will only receive results of which channels they are in

* api4/channel_test: add test case for guest accounts channel autocomplete

* apply to searchengine and also for AutocompleteInTeam

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-01 09:18:59 +03:00
Nick Misasi
cffe921e62 [MM-44475] Team Unarchive: Do not allow to unarchive if workspace has reached the limit of teams (#20281)
* Prevent cloud limited installations from restoring teams when at or above the teams limit

* Code clean up

* fix i18n

* Actually fix i18n

* updates for govet

* Update model/client4.go

Co-authored-by: Vishal <vish9812@gmail.com>

* [MM-44397] Restrict team creation based on subscription limits (#20282)

* restrict team creation based on limits

* Update api4/team.go

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* Fix tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* Add additional field to teamsusage

* Fix

* remove useless test

* Fix error for team creation

* Remove apostrophe

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Vishal <vish9812@gmail.com>
Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>
2022-05-31 15:06:54 -04:00
Ibrahim Serdar Acikgoz
a18934b042 config/diff: add utility function to get diffs scoped with struct tags (#20297)
* config/diff: add utility function to get diffs scoped with struct tags

* api4/config.go: check cloud accessible settings after merge
2022-05-31 17:10:32 +03:00
Vishal
57e9aa767c [MM-44263] Only include user posts in post count (#20250)
* Fetch users only posts

* Explicitly validate posts count before testing usage
2022-05-31 14:18:41 +05:30
Vishal
8e12d81f16 [MM-33123] Add a test for SetPostUnread-DM Channel (#20129)
* Add a test for SetPostUnread-DM Channel

* assert early

* Unread post in DM thread

* Replace th.BasicUser with u1 var

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-05-27 15:53:37 +05:30
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