Commit Graph

262 Commits

Author SHA1 Message Date
dkkb
be24f108e1 Refactor server runJobs function. (#23854) 2023-12-22 09:51:40 +01:00
Harshil Sharma
a59f5ccded Added API to return user count bands and user count (#25796) 2023-12-21 13:00:19 +00:00
Agniva De Sarker
7dcf5f85a5 MM-56071: Track multiple threads (#25775)
We can have 2 types of threads open at the same time. One from
the thread view, and another from RHS.

We add another variable to distinguish between the 2 states.

In future, if we have the ability for more than 2 threads, then
we would need to track by threadID.

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

```release-note
NONE
```
2023-12-21 08:42:58 +05:30
Matthew Straughn
ebdc964161 Mm 16623 fix all initialism errors in channels/app and channels/api4 dir (#25743)
* updated go mod and sum files

* fixed var-naming errors in channels/app and channels/api4 dir

* Revert "updated go mod and sum files"

This reverts commit 088dd00a84.

* renamed a cost .
2023-12-20 06:46:54 +01:00
Ben Schumacher
799ec680bd [MM-29240] Improve buffer handling of UploadEmojiImage (#25536) 2023-12-19 10:00:01 +01:00
Ben Schumacher
1fdddfe678 [MM-53269] Add configuration setting for integration requests timeout (#23805)
Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
2023-12-18 16:07:00 +01:00
Paul Stern
f69620f22c [MM-55299] Migrate server/channels/app/notification.go to make use of GenericStoreResult (#25746)
* [MM-55299] Make use of GenericStoreResult

Make use of GenericStoreResult in server/channels/app/notification.go

Introduce new result variables to workaround the IncompatibleAssign
error.

* [MM-55299] Make use of GenericStoreResult

Use GenericStoreResult for profiles, cmn properties, groups map.
Introduce new result variables for them to workaround IncompatibleAssign
error.

* Resolve merge conflict. Accept incoming master's change

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-12-18 13:13:56 +01:00
Paul Stern
000ee45b5d [MM-55303] channels/app/webhook: Make use of GenericStoreResult (#25722)
Make use of Generic store result in channels/app/webhook.go.
Introduce new variable resultU (result user) to workaround incompatible
assign error (since generics have been introduced).
2023-12-18 07:08:38 +01:00
Harshil Sharma
97a23d791e New report router and user reporting refactoring (#25713)
* Added materialized view migration

* Renamed mat view

* Added channel membership mat view and indexes

* Added channel membership mat view and indexes

* Added new index

* WIP

* Simplifying user reporting code

* Created app and API layer for cahnnel reporting, reporting refactoring in general

* New router

* Remobved channel reporting meanwhile

* Upodated autogenerated stuff

* Lint fix

* Fixed typo

* api vet

* i18n fix

* Fixed API vetting and removed channel reporting constants

* yaml

* removed app pagination tests
2023-12-14 10:49:19 -05:00
Daniel Espino García
917a032baf Fix MM53181 (#25684)
* Fix MM53181

* Add tests
2023-12-14 09:32:41 +01:00
Agniva De Sarker
c42ae47948 MM-56071: Thread presence indicator (#25694)
We also track the channelID of the thread opened.

Additionally on every connection create or re-connect
with an existing queue, we reset the active state to empty
to avoid any edge-cases.

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

```release-note
NONE
```
2023-12-13 13:58:40 +05:30
Agniva De Sarker
45ba1dc196 MM-55655: Fix unbounded concurrency in outgoing webhooks (#25511)
We were simply spawning goroutines within goroutines.

For each post, we would spawn one goroutine per hook,
and then one goroutine per callback URL within that hook.
And to top it off, this whole thing was itself within
a goroutine.

To fix it, we remove the goroutine spawning at a per
hook level. And then use a waitgroup to wait
until all hooks from each callback URL is complete.

While here, some other optimizations that we do:
1. We already had the channel object, but inspite of
that, we were calling channel.get again in CreatePostMissingChannel.
We just use CreatePost now and pass the channel.
2. We pre-compile the regex.
3. We store the http.Client in the server to reuse TCP connections.

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

```release-note
NONE
```
2023-12-13 09:39:22 +05:30
Agniva De Sarker
e0b5b951f1 MM-56060: Create base scaffolding for websocket pub-sub (#25654)
We create a new websocket action called "presence" which
can contain the active_channel and the active_team for a given
client connection.

On the client side, for every channel or team switch, we send
out this message.

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

```release-note
NONE
```
2023-12-12 08:49:09 +05:30
Nick Misasi
f0a336ba07 Feature: Wrangler (#23602)
* Migrate feature/wrangler to mono-repo

* Add wrangler files

* Fix linters, types, etc

* Fix snapshots

* Fix playwright

* Fix pipelines

* Fix more pipeline

* Fixes for pipelines

* More changes for pipeline

* Fix types

* Add support for a feature flag, but leave it defaulted on for spinwick usage for now

* Update snapshot

* fix js error when removing last value of multiselect, support CSV marshaling to string array for textsetting

* Fix linter

* Remove TODO

* Remove another TODO

* fix tests

* Fix i18n

* Add server tests

* Fix linter

* Fix linter

* Use proper icon for dot menu

* Update snapshot

* Add Cypress UI tests for various entrypoints to move thread modal, split SCSS out from forward post into its own thing

* clean up

* fix linter

* More cleanup

* Revert files to master

* Fix linter for e2e tests

* Make ForwardPostChannelSelect channel types configurable with a prop

* Add missing return

* Fixes from PR feedback

* First batch of PR Feedback

* Another batch of PR changes

* Fix linter

* Update snapshots

* Wrangler system messages are translated to each user's locale

* Initially translate Wrangler into system locale rather than initiating user

* More fixes for PR Feedback

* Fix some server tests

* More updates with master. Fixes around pipelines. Enforce Enterprise license on front/back end

* Add tests for dot_menu

* More pipeline fixes

* Fix e2etests prettier

* Update cypress tests, change occurrences of 'Wrangler' with 'Move Thread'

* Fix linter

* Remove enterprise lock

* A couple more occurrences of wrangler strings, and one more enterprise lock

* Fix server tests

* Fix i18n

* Fix e2e linter

* Feature flag shouldn't be on by default

* Enable move threads feature in smoke tests (#25657)

* enable move threads feature
* add @prod tag

* Fix move_thread_from_public_channel e2e test

* Fix e2e style

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
2023-12-11 15:27:34 -05:00
Ben Schumacher
5b6b425cfc [MM-56061] Only render where field in model.AppError when it's present (#25648)
* Only render where field in model.AppError when it's present

* Remove trailing comma from permission error
2023-12-11 10:27:51 +01:00
Harrison Healey
b1e745894b MM-55468 Ensure custom status emojis exist (#25501)
* MM-55468 Ensure custom status emojis exist

* Fix plugin API unit test

* Print underlying error as detailed error message

* Convert CustomStatusModal tests to React Testing Library and improve a11y

* Don't suggest custom statuses with non-existent emojis

* Silence test error by providing fake translation strings
2023-12-08 10:35:15 -05:00
Devin Binnie
109f4643c6 [MM-55017] Add API method to get users for Admin Reporting (#25499)
* Add store method to get reporting data

* Some store changes

* Added app layer

* Added API call, some miscellaneous fixes

* Fix lint

* Fix serialized check

* Add API docs

* Fix user store tests leaking users

* Fix test

* PR feedback

* Add filtering for role/team/activated user, filter out bot users

* Fix mock

* Fix test

* Oops

* Switch to using struct filter

* More PR feedback

* Fix gen

* Fix test

* Fix API docs

* Fix test

* Fix possible SQL injection, some query optimization

* Fix migrations

* Oops

* Add role to API

* Fix check

* Add Client4 API call for load testing

* Fix test

* Update server/channels/store/storetest/user_store.go

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

* PR feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2023-12-08 10:30:08 -05:00
Adam Warner
3fe68e73bf [MM-48860] / [GH-21863] Change regex to reduce false positive transforms on incoming webhook text (#21852)
* Change regex to reduce false positive transforms on incoming webhook text

Adds an additional condition to the 2nd capture group to ensure we don't match another `|` char

See https://github.com/mattermost/mattermost-server/issues/21800 for details

* Add test per suggested comment (switch Pi-hole URL out for Mattermost one 😉)

Signed-off-by: Adam Warner <me@adamwarner.co.uk>

---------

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
2023-12-06 11:12:31 -08:00
Ben Schumacher
b2ec1ff8ae [MM-55595] Use annotated logger in search layer (#25468) 2023-12-04 18:34:57 +01:00
Daniel Espino García
f6d41bcf5b Fix 55496 (#25585) 2023-12-01 10:50:57 +01:00
Devin Binnie
639181dcc1 [MM-55631] Remove extra call to Draft().Get() (#25563) 2023-11-30 10:45:32 -05:00
Daniel Espino García
2ff0fe343e [MM-45272] Fix MM-45272 (#24701)
* Fix MM-45272

* Properly handle permalinks

* Fix

* Fix tests

* Handle only not found case for team member

* Fix lint

* Use proper config value

* Separate permission in several statements

* Add tests

* Fix lint

* Revert changes on utils

* Address feedback and more fixes

* Address feedback

* Fix test

* Fix test and related bug

* Fix and reorder test

* Address feedback

* Address feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-30 11:43:51 +01:00
Ben Schumacher
c395ec6245 [MM-55990] Logger improvements for tests (#25467) 2023-11-30 10:47:04 +01:00
Thomas Brq
6cf7115e1f [GH-25492] Add the request context to all public methods in server/channels/app/admin.go (#25498) 2023-11-29 17:07:54 +01:00
Sudheer Tripathi
6e3f0ab928 [MM-55606]: add the request context to all public methods in server/channels/app/brand.go (#25542)
Co-authored-by: Sudheer Tripathi <sudheer@clearglass.com>
2023-11-29 17:07:16 +01:00
Scott Bishel
6a021a29f9 MM-55042 Fixes permissions checks (#25253)
* fix permissions check on SessionHasPermissionToTeams and SessionHasPermissionToChannels

* add tests, make updates

* remove commented code

* update to handle session permissions first

* Update authorization.go

Remove unnecessary check

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-27 09:39:38 -07:00
Devin Binnie
eaa5cce3ce [MM-55143] Disallow reacting with an emoji that does not exist, limit the total number of unique reactions per post (#25331)
* [MM-55143] Disallow reacting with an emoji that does not exist

* WIP for server limit on emoji reactions

* WIP

* Implement default limit of 25 unique emoji reactions

* Add modal for reaction limit

* Fix test

* PR feedback

* Fix i18n

* Update admin string

* Merge'd

* Fixing some issues, check limits correctly based on other users reactions

* Fix typos

* Fix lint/test

* Add tests, fix other tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-27 09:11:04 -05:00
Mikhail Fesenko
3cc3e88a57 simplified app/slashcommands/auto_teams.go: remove duplicate line of code (#21525) 2023-11-27 14:43:54 +03:00
Harshil Sharma
1a49b7e929 Added license change listener (#24342)
* Added license change listener

* Fixed location of adding license listener

* Made tests unaffected

* Minor refactoring

* Changed order of checks to avoid breaking all tests

* Using CreateJobOnce to handle HA

* Updated context

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-27 08:49:10 +05:30
Harshil Sharma
6561f6f4ff Fixed bug where channel admin wasn't set when converting GM to private channel (#25515) 2023-11-27 08:12:49 +05:30
Doug Lauder
af7bc8a4a9 Fix auto-complete in slash command for shared channel invite (#25524)
* fix auto-complete in slash command for shared channel invite

* more providers not implementing AutocompleteDynamicArgProvider

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-25 09:21:06 +01:00
KyeongSoo Kim
93cb80ef58 migrate server/channels/app/team.go to make use of generic_store_result (#25489)
Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-24 17:37:34 +01:00
Turretkeeper
8dff1ab906 Simplify preview scaling logic (#24507)
* Update preview.go

Was some complex logic in there. This should be simpler.

* Update preview.go

Make GenerateThumbnail code more verbose

* Update preview.go

Finish renaming targetHeight and targetWidth

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-23 12:27:20 -06:00
Ben Schumacher
e99ded1635 [MM-55480] Update logr to v2.0.21 (#25431) 2023-11-23 10:30:08 +01:00
Ben Schumacher
51e73b681b [MM-40638] Type all of the websocket event names as a new type WebsocketEventType (#25454)
Co-authored-by: Sudheer Tripathi <sudheer@clearglass.com>
Co-authored-by: Sudheer Tripathi <31629433+sudheer121@users.noreply.github.com>
Co-authored-by: Sudheer Tripathi <tripathisudheer604@gmail.com>
2023-11-22 11:09:48 +01:00
KyeongSoo Kim
e1f72576fb MM-52655 Allow plugin requests to include Authorization headers from external systems (#24391)
* remove the authorization header if the request is from an authenticated MM user

* fix lint

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>

---------

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-21 17:49:48 -05:00
Claudio Costa
aa3a12f183 [MM-55268] Implement ServeMetrics plugins hook (#24249)
* Implement ServeMetrics plugins hook

* Update error id

* Simplify

* Revert "Simplify"

This reverts commit c9dc5d5eac.

* Add comment and error handler

* Wrap error

* Update translation file

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-17 14:39:06 -06:00
Antonis Stamatiou
926142ca22 fix: Use version instead of build number for notices (#25435) 2023-11-17 14:37:09 +02:00
Ben Cooke
2a896f8420 [MM-54933] Add the ability to @ mention custom groups in group constrained teams and channels (#24987)
* add the ability to @ mention custom groups in group constrained teams
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-16 11:24:20 -05:00
Ben Schumacher
afb48219c0 Simplify request generation in store tests (#25422) 2023-11-16 09:51:18 +01:00
Devin Binnie
1bd72bdb99 [MM-55014][MM-55015] Add last login timestamp for users, add materialized view and refresh job to keep track of post stats for Postgres (#25152)
* [MM-55014][MM-55015] Add last login timestamp for users, add materialized view and refresh job for Postgres

* Check fixes

* Fix type issue

* Add verification that lastlogin was updated

* PR feedback

* Morge'd

* Morge'd again

* Merge'd

* Update admin setting strings

* WIP

* PR feedback

* Oops

* Fix i18n

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-14 11:26:27 -05:00
Aydın Davutoğlu
bc58437e63 [MM-55302]Migrate server/channels/app/user.go to make use of GenericStoreResult (#25409) 2023-11-14 15:13:40 +01:00
Nick Misasi
e1c851a3ca [CLD-6324] Cloud IP Filtering (#24726)
* Initial comit for ip filtering service implementation

* Add audit logs for IP Filters

* start of webapp work

* Stashing

* Updates based on Agniva's feedback around service vs einterface

* Updates completed

* Commit before refactoring, everything's working

* First pass of cleanup complete, front-end tests added

* actually add files

* Updates to some translation strings, running i18n-extract

* Lock everything behind a feature flag

* Fix tests, try to fix some linter stuff

* Fixed linter for JS, on to scss

* Fixed linter for scss

* Fix linter

* More fixes for pipeline

* Support for IPV6

* Remove tsx file that was removed in masteR

* Revert package.json and package-lock.json to master, add cidr-regex dep into channels/package.json

* Another commit to force fix Github

* Fixes around IPV6. Some suggestions from Matt re: UX review. Fixing pipelines for tests and types on new cidr-regex package

* Changes to address Matt's feedback

* A few more changes for clean up

* Add support for permissions

* Fix vet for OpenAPI spec

* Actually add the yaml file for openapi

* Add permission migration to allow support for IP Filtering

* Fix tests

* Final fixes from Matt

* Remove cancel button from page, update link outs to documentation

* Update test to account for removed cancel button

* Adjustments based on feedback from Harrison

* More fixes from PR feedback

* Add a t to fix translations that doesn't seem to be breaking anyone else?

* More fix

* updates for PR feedback

* Fix linter

* Fix types

* Now fix the linter again

* Add back tests because Harrison was able to get them running

* Adjustments for PR feedback

* Remove admin_definition.jsx

* Fix linter

* [CLD-6453] IP Filtering notification email for sysadmins (#25224)

* Initial commit for IP filtering alert email

* Updates to style for email, addition of ip_filtering email:

* Fix pipelines

* Adjustments from Matt's feedback

* Padding changes

* template diff (#25249)

Co-authored-by: Gabe Jackson <3694686+gabrieljackson@users.noreply.github.com>

* Fix hardcoded true, remove bool return value

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Gabe Jackson <3694686+gabrieljackson@users.noreply.github.com>

* Lock feature behind enterprise license. Drop cidr-regex in favour of ipaddr.js dependency. Refactor isIpAddressWithinRanges to use ipaddr.js

* Add a couple server tests

* fix linter

* Fix types from merge conflicts

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Gabe Jackson <3694686+gabrieljackson@users.noreply.github.com>
2023-11-14 09:12:04 -05:00
KIMBOH LOVETTE
29cd6177c0 [GH-21565]-Add the request context and logger to all public methods in server/channels/app/audit.go (#25368) 2023-11-14 13:34:47 +01:00
Agniva De Sarker
ec88ab4ee9 MM-55295: Improve DB performance of some APIs (#25318)
Load tests show that channelstore.GetMember and
channelstore.GetMembersForUser are among the chief
queries that take up CPU in the DB.

In this PR, we attempt some strategic optimizations to
reduce/optimize calls to channelstore.GetMember

1. Optimize  `(a *App) HasPermissionToChannel`

We replace GetChannelMember with GetAllChannelMembersForUser
because it's cache backed. So although it gets more data,
it does not hit the DB and saves some latency.

2. Optimize getPostsForChannelAroundLastUnread

We repace getChannelMember with getChannelMemberOnly
which is a lite version of the store call which queries
just the ChannelMembers table. This is because
in the app layer, we just use the LastViewedAt attribute.
Therefore, there is no reason to join with 5 tables when
a single table can do the job.

3. Optimize publishWebsocketEventForPermalinkPost

We use GetAllChannelMembersById instead of GetChannelMembersPage
which again joins with a lot of other tables.

4. Optimize countMentionsFromPost

Again, we replace GetChannelMember which is a costly call joining
multiple tables, with GetAllChannelMembersNotifyPropsForChannel
which is cache-backed and gives us just what we need in the app
layer - notify props.

```release-note
Make small optimizations in several DB calls:
- App.HasPermissionToChannel
- getPostsForChannelAroundLastUnread
- publishWebsocketEventForPermalinkPost
- countMentionsFromPost
```

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

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-13 21:15:57 +05:30
Jesse Hallam
48bf4e9bd8 Fix issue 25390 (#25403) 2023-11-10 21:55:33 -04:00
Ben Schumacher
612e4458ef [MM-55409] Enable revive linter on enterprise code (#25391) 2023-11-10 15:24:12 +01:00
Paul-Stern
7d92e71daf [MM-55299] Migrate server/channels/app/notification.go to make use of GenericStoreResult (#25338) 2023-11-10 14:45:02 +01:00
Paul-Stern
3a373fffc0 [MM-55300] Migrate "server/channels/app/post.go" to make use of GenericStoreResult (#25339)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2023-11-10 14:41:08 +01:00
Pantelis Vratsalis
d9f5cd2740 [MM-52445] Fix double url encoding of oauth redirect URI params (#23176)
* [MM-52445] Fix double url encoding of oauth redirect URI params

* Additional test based on code review

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-11-09 19:18:24 +01:00