* Pass handler functions directly without permission check middlewares
* Create necessary handlers in api4/group_local.go
* Refactor GetGroupsByTeam, GetGroupsByChannel to a common function for local and API
Channel Stats isn't optimized with dataloaders.
And it's a heavy call, therefore clients
can mistakenly call this with multiple channels
and bring down the server.
Since there is no advantage compared to a REST API,
let's just remove it and keep things safe.
```release-note
NONE
```
We were applying a white background to transparent images
and converting them to jpegs. This was to make text be legible
behind a black preview background.
However, this has led to a poor user experience, as users rarely
download the full image but always click on previews. Therefore,
we need the previews to remain as pngs.
To fix this, we just re-encode them as pngs instead of jpgs.
```release-note
NONE
```
* MM-47228 - restrict guest invitation flow if subscription plan does not support it
* fix i18n texts and add unit test
* test the scenario where guest invites are blocked by subscription
* cover the success scenarios for cloud free trial and paid subscription
* fix go vet
* use the cloud prefix for the sku
* fix unit tests
* check the licence value to determine if the guest accounts are enabled
* remove unnecessary changes for getting the subscription information
* restrict user demotion if guestAccounts is not available in license
Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
* add from_integration prop to oauth posts to:
- oauth app posts
- plugin posts
- slash command responses
- incoming webhook posts
* tests
* include check for bot posts
* use from_plugin and from_oauth_app props
* fix test
* avoid counting top channel posts for posts made by plugins and oauth apps
* MM-42191: Include deleted posts: Add includeDeleted query parameter for getPostsForChannel
* MM-42191: Fix error typo for includeDeleted query parameter
* MM-42191: Include deleted posts: Set permission error when deleted posts are requested by non system admins
* MM-42191: Include deleted posts: Refactor replyCountSubQuery and conditions when includeDeleted is not presented, refactor getRootPosts
* MM-42191: Include deleted posts: Refactor getRootPosts function along with skipFetchThreads and includeDeleted
* MM-42191: Include deleted posts: Rename includeDeleted to include_deleted param
* MM-42191: Include deleted posts: Fix failed posts unit tests
* MM-42191: Include deleted posts: Add missing include deleted option in multiple queries
* MM-42191: Include deleted posts: Add tests for include deleted option in TestGetPostsForChannel, TestGetPostsBefore, TestGetPostsAfter
* MM-42191: include deleted posts: Add tests cases for post store test
* MM-42191: Include deleted posts: Add extra unit test to ensure not returning deleted posts when IncludeDelete is false
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
The props map was being null, but the schema did not
allow nulls. Therefore, the whole response was being
set to null. There was no error which created more
confusion.
To avoid making the property nillable, which would
mean sending pointers to maps, we just create
empty maps if they are nil.
https://mattermost.atlassian.net/browse/MM-46869
```release-note
NONE
```
This PR makes 2 main changes to the tests:
1. User logins were a huge part of the total CPU time because of the constant hashing of the password. There were 3 logins every time for every `Setup()` call. We remove the `LoginSystemManager` from the Setup call as it wasn't used in a lot of tests, and call that as needed.
2. We add the new app migrations that got added after the last preload optimization was done.
This shaves off around 3 mins from the test runtime. They are down from ~18m to ~15m.
```release-note
NONE
```
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* Adds OmitConnection parameter to broadcast
Currently we have no means to omit sending a websocket event to a
specific connection id.
This is needed mainly so that the initiator won't receive an event for
the action it just initiated.
Will be used for the global drafts feature, so that we won't update
drafts through ws when a user is typing.
This commit adds OmitConnection to the Broadcast struct and to the
NewWebSocketEvent function signature.
shouldSendEvent should return false for that specific connection.
* Return early only if connection id matches the omitted
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* Add api endpoints, app layers for top inactive channels with dummy store calls
* Add store functions for top inactive channels
* Add model, store, app tests.
* Add client function and api tests
* Add participants information to TopInactiveChannel
* Translation fix
* Style fix while writing response
* Return channelmember IDs instead of profiles, query in batch avoiding inside the loop
* Make the following changes
- move DeleteAt to subqueries, to avoid select, group by
- Remove TeamId from response
- Count bots and webhook posts
* SQL query lint fix, store test fix to include bot messages
* make app-layers
* Fix empty participant lists being sent as [""]
* Track channel joins, to distinguish 0 activity channels vs new channels
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* MM-45120: Starts tracking team join time. Adds API to retrieve team members who joined after a given time.
* MM-45120: Updates json casing to match model.User.
There were lots of cases where we were using the code 501
in an incorrect manner, and since 5xx codes are considered
as SLO violations, these were flagged by our monitoring incorrectly.
These were the guidelines to change the codes:
1. Any case of missing license or config not correctly enabled
is set as Forbidden. The logic is that the user is correctly
authenticated with a session, but does not have enough privileges
to have the higher license, or hasn't changed the config correctly.
2. Any case of incorrectly formed request is obviously a 400.
https://mattermost.atlassian.net/browse/MM-43202
```release-note
NONE
```