Commit graph

1695 commits

Author SHA1 Message Date
Harshil Sharma
79756ae1e1
Reviewer search api (#34036)
* Added another property field

* WIP

* WIP

* Added validations

* Added data validations and hidden post if confifgured to

* lint fixes

* Added API spec

* Added some tests

* Added tests for getContentReviewBot

* test: add comprehensive tests for getContentReviewChannels function

* Added more app layer tests

* Added TestCanFlagPost

* test: Add comprehensive tests for FlagPost function

* Added all app layer tests

* Removed a file that was reamoved downstream

* test: add content flagging test file

* test: add comprehensive tests for FlagContentRequest.IsValid method

* Added model tests

* test: add comprehensive tests for SqlPropertyValueStore.CreateMany

* test: add comprehensive tests for flagPost() API function

* Added API tests

* linter fix

* WIP

* sent post flagging confirmation message

* fixed i18n nissues

* fixed i18n nissues

* CI

* WIP

* WIP

* Added API call

* test: add test for Client4.flagPost API call in FlagPostModal

* fix: remove userEvent.setup() from flag post modal test

* test: wrap submit button click in act for proper state updates

* Updated tests

* lint fix

* Updated test

* fix: reset contentFlaggingGroupId for test isolation in content flagging tests

* removed cached group ID

* removed debug log

* CI

* Updated to allow special characters in comments

* Handled empty comment

* Created getContentFlaggingFields API

* created getPostPropertyValues API

* Used finally

* WIP

* Created useContentFlaggingFields hook

* WIP

* WIP

* Added option to retain data for reviewers

* Displayed deleted post's preview

* DIsplayed all properties

* Adding field name i18n

* WIP - managing i18n able texts

* Finished displaying all fields

* Manual cleanup

* lint fixes

* team role filter logic fix

* Fixed tests

* created new API to fetch flagged posts

* lint fix

* Added new client methods

* test: add comprehensive tests for content flagging APIs

* Added new API tests

* fixed openapi spec

* Fixed DataSpillageReport tests

* Fixed PostMarkdown test

* Fixed PostPreviewPropertyRenderer test

* Added metadata to card renderer

* test fixes

* Added no comment placeholder

* Added view detail button

* Created RemoveFlaggedMessageConfirmationModal modal

* Added key and remove flag request modal

* IMplemented delete flagged post

* Handled edge cases of deleting flagged post

* keep message

* UI integration

* Added WS event for post report update and handled deleted files of flagged post

* Added error handling in keep/remove forms

* i18n fixes

* Fixed test

* Updated OpenAPI specs

* fixed types

* fixed types

* refactoring

* refactor: improve test mocking for data spillage report component

* test mock updates

* Fixed tests

* Updated reducer

* not resetting mocks

* Added migrations for content flagging tables

* Created new structure

* review fixes

* Used correct ot name

* WIP

* review fixes

* review fixes

* Added new property translations

* CI

* CI

* CI

* Improved test

* fixed test

* CI

* New UI component

* WIP

* Updated settings APIs

* cached DB data

* used cached reviewer data

* Updated tests

* Lint fixes

* test: add tests for saveContentFlaggingSettings and getContentFlaggingSettings APIs

* test fix

* test: add tests for SaveContentFlaggingConfig and GetContentFlaggingConfigReviewerIDs

* Updated tests

* test: add content flagging test for local cache layer

* test: add comprehensive tests for content flagging store cache

* Updated tests

* lint fix

* Updated mobile text

* Added content flagging SQL store mocks

* Added API specs for new APIs

* fixed tests

* feat: add TestContentFlaggingStore function for content flagging store testing

* feat: add comprehensive tests for content flagging store

* Added SQL store tests

* test: add content flagging test for local cache layer

* test: add tests for content flagging store caching

* Added cache layer tests

* Updated tests

* Fixed

* Handled JSON error

* fixes

* fixes

* Fixed retry layer test

* fixerdf i18n

* Fixed test

* CI

* building index concurrently

* CI

* fixed a test

* CI

* cleanup

* Implemented reviewer search API

* feat: add tests for SearchCommonContentFlaggingReviewers and SearchTeamContentFlaggingReviewers

* Added store tests

* test: add comprehensive tests for SearchReviewers function

* feat: add comprehensive tests for searchReviewers endpoint

* API tests

* Integrate flag post api (#33798)

* WIP

* WIP

* Added API call

* test: add test for Client4.flagPost API call in FlagPostModal

* fix: remove userEvent.setup() from flag post modal test

* test: wrap submit button click in act for proper state updates

* Updated tests

* lint fix

* CI

* Updated to allow special characters in comments

* Handled empty comment

* Used finally

* CI

* Fixed test

* Spillage card integration (#33832)

* Created getContentFlaggingFields API

* created getPostPropertyValues API

* WIP

* Created useContentFlaggingFields hook

* WIP

* WIP

* Added option to retain data for reviewers

* Displayed deleted post's preview

* DIsplayed all properties

* Adding field name i18n

* WIP - managing i18n able texts

* Finished displaying all fields

* Manual cleanup

* lint fixes

* team role filter logic fix

* Fixed tests

* created new API to fetch flagged posts

* lint fix

* Added new client methods

* test: add comprehensive tests for content flagging APIs

* Added new API tests

* fixed openapi spec

* Fixed DataSpillageReport tests

* Fixed PostMarkdown test

* Fixed PostPreviewPropertyRenderer test

* Added metadata to card renderer

* test fixes

* Added no comment placeholder

* Fixed test

* refactor: improve test mocking for data spillage report component

* test mock updates

* Updated reducer

* not resetting mocks

* WIP

* review fixes

* CI

* Fixed

* fixes

* Content flagging actions implementation (#33852)

* Added view detail button

* Created RemoveFlaggedMessageConfirmationModal modal

* Added key and remove flag request modal

* IMplemented delete flagged post

* Handled edge cases of deleting flagged post

* keep message

* UI integration

* Added WS event for post report update and handled deleted files of flagged post

* Added error handling in keep/remove forms

* i18n fixes

* Updated OpenAPI specs

* fixed types

* fixed types

* refactoring

* Fixed tests

* review fixes

* Added new property translations

* Improved test

* fixed test

* CI

* fixes

* CI

* fixed a test

* fixed  abad commit

* CI

* WIP

* IMplemented assign reviewer API

* Display reviewers

* Review fixes

* UI integration

* lint fix

* Added API docs

* test: add comprehensive tests for assignFlaggedPostReviewer function

* test: add comprehensive tests for AssignFlaggedPostReviewer

* Added tests

* Fixed test

* Sequential tests

* minor improvemenmts

* WIP

* Added keep/delete message notifications

* refactor: update AssignFlaggedPostReviewer method signature to include context

* test: add tests for getReviewerPostsForFlaggedPost and postReviewerMessage

* lint fixes

* handled reviewer updates

* Handled preference

* review fixes

* Review fixes
2025-10-14 09:06:23 +05:30
Jesse Hallam
9c6179eea2
Fix ActiveUserCount check to ignore when MaxUsersLimit == 0 (#34114)
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Waiting to run
Web App CI / check-types (push) Waiting to run
Web App CI / test (push) Waiting to run
Web App CI / build (push) Waiting to run
Add missing MaxUsersLimit > 0 check before comparing ActiveUserCount,
consistent with similar check in createUserOrGuest function.
2025-10-13 13:19:00 -04:00
Harshil Sharma
3265054ad5
Migrate content flagging settings to database (#33989)
Some checks failed
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Waiting to run
Web App CI / check-types (push) Waiting to run
Web App CI / test (push) Waiting to run
Web App CI / build (push) Waiting to run
Migration-assist Sync / Check if migration-assist have been synced (push) Has been cancelled
* lint fix

* CI

* added new migration mocks

* Used setup for tests

* some comment

* Removed unnecesseery nil check

* Form validation

* WIP tests

* WIP tests

* WIP tests

* fix: mock content flagging config selector with correct reasons format

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

* fix: add mock for getContentFlaggingConfig in flag post modal test

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

* Updated error code order in API docs

* removed empty files

* Added tests

* lint fixes

* minor tweak

* lint fix

* type fix

* fixed test

* nit

* test enhancements

* API WIP

* API WIP

* creating values

* creating content flagging channel and properties

* Able to save properties

* Added another property field

* WIP

* WIP

* Added validations

* Added data validations and hidden post if confifgured to

* lint fixes

* Added API spec

* Added some tests

* Added tests for getContentReviewBot

* test: add comprehensive tests for getContentReviewChannels function

* Added more app layer tests

* Added TestCanFlagPost

* test: Add comprehensive tests for FlagPost function

* Added all app layer tests

* Removed a file that was reamoved downstream

* test: add content flagging test file

* test: add comprehensive tests for FlagContentRequest.IsValid method

* Added model tests

* test: add comprehensive tests for SqlPropertyValueStore.CreateMany

* test: add comprehensive tests for flagPost() API function

* Added API tests

* linter fix

* WIP

* sent post flagging confirmation message

* fixed i18n nissues

* fixed i18n nissues

* CI

* WIP

* WIP

* Added API call

* test: add test for Client4.flagPost API call in FlagPostModal

* fix: remove userEvent.setup() from flag post modal test

* test: wrap submit button click in act for proper state updates

* Updated tests

* lint fix

* Updated test

* fix: reset contentFlaggingGroupId for test isolation in content flagging tests

* removed cached group ID

* removed debug log

* CI

* Updated to allow special characters in comments

* Handled empty comment

* Created getContentFlaggingFields API

* created getPostPropertyValues API

* Used finally

* WIP

* Created useContentFlaggingFields hook

* WIP

* WIP

* Added option to retain data for reviewers

* Displayed deleted post's preview

* DIsplayed all properties

* Adding field name i18n

* WIP - managing i18n able texts

* Finished displaying all fields

* Manual cleanup

* lint fixes

* team role filter logic fix

* Fixed tests

* created new API to fetch flagged posts

* lint fix

* Added new client methods

* test: add comprehensive tests for content flagging APIs

* Added new API tests

* fixed openapi spec

* Fixed DataSpillageReport tests

* Fixed PostMarkdown test

* Fixed PostPreviewPropertyRenderer test

* Added metadata to card renderer

* test fixes

* Added no comment placeholder

* Added view detail button

* Created RemoveFlaggedMessageConfirmationModal modal

* Added key and remove flag request modal

* IMplemented delete flagged post

* Handled edge cases of deleting flagged post

* keep message

* UI integration

* Added WS event for post report update and handled deleted files of flagged post

* Added error handling in keep/remove forms

* i18n fixes

* Fixed test

* Updated OpenAPI specs

* fixed types

* fixed types

* refactoring

* refactor: improve test mocking for data spillage report component

* test mock updates

* Fixed tests

* Updated reducer

* not resetting mocks

* Added migrations for content flagging tables

* Created new structure

* review fixes

* Used correct ot name

* WIP

* review fixes

* review fixes

* Added new property translations

* CI

* CI

* CI

* Improved test

* fixed test

* CI

* New UI component

* WIP

* Updated settings APIs

* cached DB data

* used cached reviewer data

* Updated tests

* Lint fixes

* test: add tests for saveContentFlaggingSettings and getContentFlaggingSettings APIs

* test fix

* test: add tests for SaveContentFlaggingConfig and GetContentFlaggingConfigReviewerIDs

* Updated tests

* test: add content flagging test for local cache layer

* test: add comprehensive tests for content flagging store cache

* Updated tests

* lint fix

* Updated mobile text

* Added content flagging SQL store mocks

* Added API specs for new APIs

* fixed tests

* feat: add TestContentFlaggingStore function for content flagging store testing

* feat: add comprehensive tests for content flagging store

* Added SQL store tests

* test: add content flagging test for local cache layer

* test: add tests for content flagging store caching

* Added cache layer tests

* Updated tests

* Fixed

* Handled JSON error

* fixes

* fixes

* Fixed retry layer test

* fixerdf i18n

* Fixed test

* CI

* building index concurrently

* CI

* fixed a test

* CI

* cleanup

* Integrate flag post api (#33798)

* WIP

* WIP

* Added API call

* test: add test for Client4.flagPost API call in FlagPostModal

* fix: remove userEvent.setup() from flag post modal test

* test: wrap submit button click in act for proper state updates

* Updated tests

* lint fix

* CI

* Updated to allow special characters in comments

* Handled empty comment

* Used finally

* CI

* Fixed test

* Spillage card integration (#33832)

* Created getContentFlaggingFields API

* created getPostPropertyValues API

* WIP

* Created useContentFlaggingFields hook

* WIP

* WIP

* Added option to retain data for reviewers

* Displayed deleted post's preview

* DIsplayed all properties

* Adding field name i18n

* WIP - managing i18n able texts

* Finished displaying all fields

* Manual cleanup

* lint fixes

* team role filter logic fix

* Fixed tests

* created new API to fetch flagged posts

* lint fix

* Added new client methods

* test: add comprehensive tests for content flagging APIs

* Added new API tests

* fixed openapi spec

* Fixed DataSpillageReport tests

* Fixed PostMarkdown test

* Fixed PostPreviewPropertyRenderer test

* Added metadata to card renderer

* test fixes

* Added no comment placeholder

* Fixed test

* refactor: improve test mocking for data spillage report component

* test mock updates

* Updated reducer

* not resetting mocks

* WIP

* review fixes

* CI

* Fixed

* fixes

* Content flagging actions implementation (#33852)

* Added view detail button

* Created RemoveFlaggedMessageConfirmationModal modal

* Added key and remove flag request modal

* IMplemented delete flagged post

* Handled edge cases of deleting flagged post

* keep message

* UI integration

* Added WS event for post report update and handled deleted files of flagged post

* Added error handling in keep/remove forms

* i18n fixes

* Updated OpenAPI specs

* fixed types

* fixed types

* refactoring

* Fixed tests

* review fixes

* Added new property translations

* Improved test

* fixed test

* CI

* fixes

* CI

* fixed a test

* CI

* Review fixes

---------

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>
2025-10-13 12:24:01 +05:30
Alejandro García Montoro
d3eb6cbf1c
Revert "MM-13657: Set ExperimentalStrictCSRFEnforcement to true by default (#33444)" (#34112)
Some checks failed
API / build (push) Has been cancelled
Server CI / Compute Go Version (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / test (push) Has been cancelled
Web App CI / build (push) Has been cancelled
Server CI / Check mocks (push) Has been cancelled
Server CI / Check go mod tidy (push) Has been cancelled
Server CI / check-style (push) Has been cancelled
Server CI / Check serialization methods for hot structs (push) Has been cancelled
Server CI / Vet API (push) Has been cancelled
Server CI / Check migration files (push) Has been cancelled
Server CI / Generate email templates (push) Has been cancelled
Server CI / Check store layers (push) Has been cancelled
Server CI / Check mmctl docs (push) Has been cancelled
Server CI / Postgres with binary parameters (push) Has been cancelled
Server CI / Postgres (push) Has been cancelled
Server CI / Postgres (FIPS) (push) Has been cancelled
Server CI / Generate Test Coverage (push) Has been cancelled
Server CI / Run mmctl tests (push) Has been cancelled
Server CI / Run mmctl tests (FIPS) (push) Has been cancelled
Server CI / Build mattermost server app (push) Has been cancelled
* Revert "MM-13657: Set ExperimentalStrictCSRFEnforcement to true by default (#33444)"

This reverts commit 257eec43ed.

* Fix call to checkCSRFToken

* Adapt test that relied on strict CSRF enforcement

This test was added after
https://github.com/mattermost/mattermost/pull/33444, so it assumed
strict CSRF enforcement to be enabled. When reverting that PR, we need
to adapt the test to account for both cases.

* Fix newer tests to use older setting
2025-10-10 19:15:45 +02:00
Ibrahim Serdar Acikgoz
5e46ce3ff5
[MM-64541] fix flaky test TestUnassignPoliciesFromChannels (#34081) 2025-10-10 10:33:07 +02:00
Guillermo Vayá
dfa0128552
[MM-65769] add updatedSince to field search (#34037)
* add updatedSince to field search

* Update server/public/model/property_field.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-08 10:54:29 +00:00
Jesse Hallam
057efca74e
MM-65743: Sanitize in email verification endpoint (#33914)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-10-07 19:46:01 +00:00
Ben Schumacher
71579a85a6
[MM-64633] Rewrite Go client using Generics (#31805)
Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
2025-10-07 12:19:21 +02:00
Harshil Sharma
c21ef29f02
Flag post API (#33765)
* Added enable/disable setting and feature flag

* added rest of notifgication settings

* Added backend for content flagging setting and populated notification values from server side defaults

* WIP user selector

* Added common reviewers UI

* Added additonal reviewers section

* WIP

* WIP

* Team table base

* Added search in teams

* Added search in teams

* Added additional settings section

* WIP

* Inbtegrated reviewers settings

* WIP

* WIP

* Added server side validation

* cleanup

* cleanup

* [skip ci]

* Some refactoring

* type fixes

* lint fix

* test: add content flagging settings test file

* test: add comprehensive unit tests for content flagging settings

* enhanced tests

* test: add test file for content flagging additional settings

* test: add comprehensive unit tests for ContentFlaggingAdditionalSettingsSection

* Added additoonal settings test

* test: add empty test file for team reviewers section

* test: add comprehensive unit tests for TeamReviewersSection component

* test: update tests to handle async data fetching in team reviewers section

* test: add empty test file for content reviewers component

* feat: add comprehensive unit tests for ContentFlaggingContentReviewers component

* Added ContentFlaggingContentReviewersContentFlaggingContentReviewers test

* test: add notification settings test file for content flagging

* test: add comprehensive unit tests for content flagging notification settings

* Added ContentFlaggingNotificationSettingsSection tests

* test: add user profile pill test file

* test: add comprehensive unit tests for UserProfilePill component

* refactor: Replace enzyme shallow with renderWithContext in user_profile_pill tests

* Added UserProfilePill tests

* test: add empty test file for content reviewers team option

* test: add comprehensive unit tests for TeamOptionComponent

* Added TeamOptionComponent tests

* test: add empty test file for reason_option component

* test: add comprehensive unit tests for ReasonOption component

* Added ReasonOption tests

* cleanup

* Fixed i18n error

* fixed e2e test lijnt issues

* Updated test cases

* Added snaoshot

* Updated snaoshot

* lint fix

* WIP

* lint fix

* Added post flagging properties setup

* review fixes

* updated snapshot

* CI

* Added base APIs

* Fetched team status data on load and team switch

* WIP

* Review fixes

* wip

* WIP

* Removed an test, updated comment

* CI

* Added tests

* Added tests

* Lint fix

* Added API specs

* Fixed types

* CI fixes

* API tests

* lint fixes

* Set env variable so API routes are regiustered

* Test update

* term renaming and disabling API tests on MySQL

* typo

* Updated store type definition

* Minor tweaks

* Added tests

* Removed error in app startup when content flaghging setup fails

* Updated sync condition:

* Flag message modal basE

* added post preview

* displaying options

* Adde comment input

* Updated tests and docs

* finction rename

* WIP

* Updated tests

* refactor

* lint fix

* MOved to data migration

* lint fix

* CI

* added new migration mocks

* Used setup for tests

* some comment

* Removed unnecesseery nil check

* Form validation

* WIP tests

* WIP tests

* WIP tests

* fix: mock content flagging config selector with correct reasons format

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

* fix: add mock for getContentFlaggingConfig in flag post modal test

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

* Updated error code order in API docs

* removed empty files

* Added tests

* lint fixes

* minor tweak

* lint fix

* type fix

* fixed test

* nit

* test enhancements

* API WIP

* API WIP

* creating values

* creating content flagging channel and properties

* Able to save properties

* Added another property field

* WIP

* WIP

* Added validations

* Added data validations and hidden post if confifgured to

* lint fixes

* Added API spec

* Added some tests

* Added tests for getContentReviewBot

* test: add comprehensive tests for getContentReviewChannels function

* Added more app layer tests

* Added TestCanFlagPost

* test: Add comprehensive tests for FlagPost function

* Added all app layer tests

* Removed a file that was reamoved downstream

* test: add content flagging test file

* test: add comprehensive tests for FlagContentRequest.IsValid method

* Added model tests

* test: add comprehensive tests for SqlPropertyValueStore.CreateMany

* test: add comprehensive tests for flagPost() API function

* Added API tests

* linter fix

* WIP

* sent post flagging confirmation message

* fixed i18n nissues

* fixed i18n nissues

* CI

* Updated test

* fix: reset contentFlaggingGroupId for test isolation in content flagging tests

* removed cached group ID

* removed debug log

* review fixes

* Used correct ot name

* CI

* Updated mobile text

* Handled JSON error

* fixerdf i18n

* CI

* Integrate flag post api (#33798)

* WIP

* WIP

* Added API call

* test: add test for Client4.flagPost API call in FlagPostModal

* fix: remove userEvent.setup() from flag post modal test

* test: wrap submit button click in act for proper state updates

* Updated tests

* lint fix

* CI

* Updated to allow special characters in comments

* Handled empty comment

* Used finally

* CI

* Fixed test

* Spillage card integration (#33832)

* Created getContentFlaggingFields API

* created getPostPropertyValues API

* WIP

* Created useContentFlaggingFields hook

* WIP

* WIP

* Added option to retain data for reviewers

* Displayed deleted post's preview

* DIsplayed all properties

* Adding field name i18n

* WIP - managing i18n able texts

* Finished displaying all fields

* Manual cleanup

* lint fixes

* team role filter logic fix

* Fixed tests

* created new API to fetch flagged posts

* lint fix

* Added new client methods

* test: add comprehensive tests for content flagging APIs

* Added new API tests

* fixed openapi spec

* Fixed DataSpillageReport tests

* Fixed PostMarkdown test

* Fixed PostPreviewPropertyRenderer test

* Added metadata to card renderer

* test fixes

* Added no comment placeholder

* Fixed test

* refactor: improve test mocking for data spillage report component

* test mock updates

* Updated reducer

* not resetting mocks

* WIP

* review fixes

* CI

* Fixed

* fixes

* Content flagging actions implementation (#33852)

* Added view detail button

* Created RemoveFlaggedMessageConfirmationModal modal

* Added key and remove flag request modal

* IMplemented delete flagged post

* Handled edge cases of deleting flagged post

* keep message

* UI integration

* Added WS event for post report update and handled deleted files of flagged post

* Added error handling in keep/remove forms

* i18n fixes

* Updated OpenAPI specs

* fixed types

* fixed types

* refactoring

* Fixed tests

* review fixes

* Added new property translations

* Improved test

* fixed test

* CI

* fixes

* CI

* fixed a test

* CI

---------

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>
2025-10-02 20:24:29 +05:30
Alejandro García Montoro
e5fbe65a0b
MM-66071: Do not error on empty slice in /groups/names (#34021)
* Do not error on empty slice in /groups/names

If group_names is an empty slice, this should not be an invalid
parameter. We return what we were asked for: an empty array.

* Avoid requests to /groups/names if list is empty

If the list of group names is empty, we do not need to ask the server
for the corresponding groups: we already know it'll be an empty list.
2025-10-02 09:59:09 +02:00
Eva Sarafianou
3ac4a73c63
[MM-65837], [MM-65824] - Update Dependencies (#33972)
* Update github.com/mholt/archives

* Update github.com/spf13/viper

* make batch migration worker tests less flaky

---------

Co-authored-by: Jesse Hallam <jesse@mattermost.com>
2025-10-01 20:19:22 +00:00
Pablo Vélez
b311da87a4
Mm 65123 remove channel abac ff (#33953)
* MM-65123 - remove channel abac feature flag

* enable the channel scope access control to true

* fix linters

* adjust expected error in tests

* remove no longer needed comment

* Remove write_restrictable from core ABAC settings and fix channel access control logic

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-10-01 16:12:36 +02:00
Alejandro García Montoro
6eacd7c534
Bump Postgres minimum supported version to 14 (#34010) 2025-10-01 09:49:05 +02:00
Devin Binnie
47aa32f0fc
[MM-61899] Properly restrict users who previously shared a team from DMs/GMs when they no longer share a team. (#30094)
* [MM-61899] Properly restrict users who previously shared a team from DMs/GMs when they no longer share a team.

* Fix checks

* Fix test

* Fix i18n

* Added E2E tests

* Merge'd

* Add restricted DM check to more places

* Merge'd

* Restrict patching the channel (updating the channel)

* Update verbiage in the admin console

* Fix lint

* More tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-30 11:41:14 -04:00
JG Heithcock
a41db04d27
MM 65084 server-side (#33861)
* MM-65084: (server-side) PKCE code-exchange for SSO

Server side changes needed for MM-65084. Guarded by MobileSSOCodeExchange feature flag.

* Update users.yaml for vet-api testing

* Change error for not saving SAML token to existing generic 'can't save token' message

* Restricting to sha256 only PKCEs

* Change out PKCE terminology to SAML

This came out as Claude used "PKCE" as a shorthand for the style and I did not know better. SAML is the correct term here.
This also fixes a linter issue where we were assigning `codeVerifier` to `computed` but then overwriting it in all cases (so that was misleading and unecessary)

* Adding ConsumeTokenOnce and IsExpired as suggested by security review

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-29 14:29:32 -07:00
Scott Bishel
f8b3ce4e3b
Add multiform functionality to Interactivedialog (#33076)
* Implement Interactive Dialog field refresh and multi-step form functionality

- Add field refresh capability to interactive dialogs
- Implement multi-step form support
- Add comprehensive E2E tests for new features
- Enhance InteractiveDialogAdapter with server-side error handling
- Optimize form validation and performance
- Add internationalization support for error messages
- Maintain backward compatibility with existing dialogs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fixes and cleanup

* Enhance field refresh e2e tests with improved field ordering and form submission

- Reverse field order: project name first, then project type (with refresh)
- Ensure all tests enter project name to verify value preservation
- Add form submission to MM-T2540B test to verify complete workflow
- Update webhook server to preserve project name values during refresh
- Add submission handler for field refresh dialog callback
- Update introduction text to reflect new field ordering workflow

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* code review updates

* Simplify apps form value preservation by always merging previous values

- Remove AppFormUpdateType enum and updateType props throughout apps form system
- Simplify getDerivedStateFromProps to always preserve existing values via spread operator
- Remove restoreFormFieldValues function and manual value restoration logic
- Eliminate conditional refresh vs submit behavior in favor of consistent value preservation

This change makes apps form behavior consistent regardless of whether it's a
multi-step submission or field refresh, improving reliability and reducing complexity.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add server-side validation for SubmitDialogResponse

- Add SubmitDialogResponseType enum with OK, Form, Navigate, and Empty types
- Implement IsValid() method with fail-fast validation logic
- Validate type field and ensure Form field consistency based on type
- Add comprehensive test coverage for all validation scenarios
- Integration validates responses in SubmitInteractiveDialog handler

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* lint fixes

* Fix test case for multierror format in Dialog.IsValid()

The Dialog.IsValid() method returns multierror format, so the test
expectation needs to match the actual error format with line breaks.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* i18n-extract

* log dialog errors, allow invalid dialog

* Fix interactive dialog test assertions for undefined values

Handle cases where dialog elements have undefined default values or
placeholders by providing empty string fallbacks. This resolves CI
test failures where undefined values were expected but empty strings
were returned from DOM elements.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-26 11:09:50 -06:00
Guillermo Vayá
9d16035212
[MM-65769] Add UpdatedSince to properties search in pluginapi (#33959)
* add since to properties search

* improve testing

* fix tests

* address naming concerns

* adapt comments to new naming

* style fixes

* who you gonna call?
2025-09-26 13:14:29 +02:00
Pablo Vélez
de686b80bf
MM-65661 - channel admin abac override previous jobs (#33872)
* MM-65661 - channel admin abac override previous jobs

* more UX adjustments; always show the self-exclusion warning modal

* use SubjectID parameter for more performant user lookup instead of fetching all matching users

* improve validation of result based on PR feedback

* performance optimization and DoS protection for access control sync jobs

* refactor: rename context parameter from 'c' to 'rctx' in job-related functions for consistency

* prevent duplicate save button clicks with immediate response and remove unnecessary debouncing time

* remove dedicated endpoint and unify logic

* improve filtering performance by including statuses

* use a flag to use master directly to prevent db replication lags

* adjust unit tests based on pr feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-26 12:33:31 +02:00
Miguel de la Cruz
f5693467db
Adds value endpoints to local mode (#33950)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-09-26 10:57:13 +02:00
Ben Schumacher
bd8bbcb503
Fix bad merge (#33949) 2025-09-23 11:34:04 +02:00
Ben Schumacher
d203ab7ee5
[MM-62582] Don't require email address verification for SAML/LDAP users when their email address changes (#30308)
* Don't invalidate email adress of SAML/LDAP users

* Add lazy migration to fix broken records
2025-09-23 09:39:19 +02:00
Ben Schumacher
18eb1347db
[MM-64900] Migrate to use request.CTX instead of context.Context (#33541)
* Migrate GetRoleByName

* Migrate users GetUsers

* Migrate Post and Thread store

* Migrate channel store

* Fix TestConvertGroupMessageToChannel

* Fix TestGetMemberCountsByGroup

* Fix TestPostStoreLastPostTimeCache
2025-09-18 16:14:24 +02:00
Miguel de la Cruz
f6ce0e439e
Improve self checks when adding a new channel member (#33404)
* Improve self checks when adding a new channel member

* Fix linter

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-17 10:20:58 +00:00
Jesse Hallam
8d74c6c45c
MM-64395: Remove unused searchArchivedChannelsForTeam API and implementations (#33885)
The searchArchivedChannelsForTeam functionality has been superseded by the
searchAllChannels API with include_deleted parameter. The Browse Channels modal
and other UI components now use the modern searchAllChannels approach.

Fixes: https://mattermost.atlassian.net/browse/MM-64395
2025-09-16 09:51:37 -03:00
Miguel de la Cruz
b3c4aa4cc8
Ensures new CPA fields are created without DeleteAt set (#33652)
* Ensures new CPA fields are created without DeleteAt set

* Move the DeleteAt check to the main property logic

* Apply timestamps unconditinally as this method is only run before creating a new field

* Fix the linter and test

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-09-16 11:19:18 +00:00
Ben Schumacher
832d033785
[MM-64517] Fix NPE in PluginSettings.Sanitize (#31361)
* Fix NPE in PluginSettings.Sanitize

* Don't return settings that the plugin doesn't define any longer

* Fix TestPluginAPILoadPluginConfiguration

* Apply suggestions from code review

* Update server/public/model/config.go

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-16 12:57:28 +02:00
Maria A Nunez
072c402e49
Team Edition User Limit Update (#33888)
* Lower user limit for TE to final limit

* Added warning banner for user soft limit

* Linting

* Fix test

* Fix tests
2025-09-15 11:39:52 -04:00
Jesse Hallam
06b1bf3a51
MM-64878: FIPS Build (#33809)
* pin to ubuntu-24.04

* always use FIPS compatible Postgres settings

* use sha256 for remote cluster IDs

* use sha256 for client config hash

* rework S3 backend to be FIPS compatible

* skip setup-node during build, since already in container

* support FIPS builds

* Dockerfile for FIPS image, using glibc-openssl-fips

* workaround entrypoint inconsistencies

* authenticate to DockerHub

* fix FIPS_ENABLED, add test-mmctl-fips

* decouple check-mattermost-vet from test/build steps

* fixup! decouple check-mattermost-vet from test/build steps

* only build-linux-amd64 for fips

* rm entrypoint workaround

* tweak comment grammar

* rm unused Dockerfile.fips (for now)

* ignore gpg import errors, since would fail later anyway

* for fips, only make package-linux-amd64

* set FIPS_ENABLED for build step

* Add a FIPS-specific list of prepackaged plugins

Note that the names are still temporary, since they are not uploaded to
S3 yet. We may need to tweak them when that happens.

* s/golangci-lint/check-style/

This ensures we run all the `check-style` checks: previously,
`modernize` was missing.

* pin go-vet to @v2, remove annoying comment

* add -fips to linux-amd64.tz.gz package

* rm unused setup-chainctl

* use BUILD_TYPE_NAME instead

* mv fips build to enterprise-only

* fixup! use BUILD_TYPE_NAME instead

* temporarily pre-package no plugins for FIPS

* split package-cleanup

* undo package-cleanup, just skip ARM, also test

* skip arm for FIPS in second target too

* fmt Makefile

* Revert "rm unused Dockerfile.fips (for now)"

This reverts commit 601e37e0ff.

* reintroduce Dockerfile.fips and align with existing Dockerfile

* s/IMAGE/BUILD_IMAGE/

* bump the glibc-openssl-fips version

* rm redundant comment

* fix FIPS checks

* set PLUGIN_PACKAGES empty until prepackaged plugins ready

* upgrade glibc-openssl-fips, use non-dev version for final stage

* another BUILD_IMAGE case

* Prepackage the FIPS versions of plugins

* relocate FIPS_ENABLED initialization before use

* s/Config File MD5/Config File Hash/

* Update the FIPS plugin names and encode the + sign

* add /var/tmp for local socket manipulation

---------

Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-15 10:53:28 -03:00
Pablo Vélez
f2f83187b8
MM-65618 - filter based on admin values (#33857)
* MM-65618 - filter based on admin values

* add open api documentation

* adjust api description and adjust UX to match design

* reorganize function and add unit tests

* more UX adjustments; always show the self-exclusion warning modal

* use SubjectID parameter for more performant user lookup instead of fetching all matching users

* fix unit tests and remove wrong condition for job run

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-12 20:09:47 +02:00
Miguel de la Cruz
aad2fa1461
Adds Custom Profile Attributes value commands to mmctl (#33881)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-09-12 17:59:40 +02:00
catalintomai
7d8b7b5e4a
MM-63930: Lack of MFA enforcement in Websocket connections (#33381) 2025-09-12 08:35:06 +02:00
Julien Tant
78050bb0d3
Change properties search signature to support multiple TargetIDs (#33873)
* change properties search

* add tests

* Fix calls to to the search methods

* Fix SearchPropertyFields call with wrong signature
2025-09-11 22:56:01 +00:00
Guillermo Vayá
d15b933888
[MM-64683] Implement property field counting functionality in Plugin API (#33438)
* Implement property field limit enforcement and counting functionality in Plugin API

- Added a limit of 20 property fields per group in the CreatePropertyField method.
- Introduced CountPropertyFields method to count active and all property fields, including deleted ones.
- Enhanced tests to validate the new property field limit and counting behavior.
- Updated related API and service methods to support the new functionality.

* Update server/channels/app/properties/property_field.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix vet

* fix lint error

* fix test

* fix tests

* fix test

* count properties + targets

* Update server/channels/app/plugin_api.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* remove test for limit

* fix more tests

* improve testing messages now that the limit is removed

* Apply suggestion from @calebroseland

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>

* Apply suggestion from @calebroseland

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>

* Apply suggestion from @calebroseland

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>

* Apply suggestion from @calebroseland

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Julien Tant <785518+JulienTant@users.noreply.github.com>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2025-09-11 12:49:14 -07:00
Pablo Vélez
a062239402
MM-65182 - auto disable toggle on rules deleted and permissions update (#33810)
* MM-65182 - auto disable toggle on rules deleted and channel admin permissions update

* fix types and fix unit test

* adjust the useEffect hook and fix auto-save issue

* MM-65183 - rename access rules tab to access control (#33812)

* fix infinite loop issue and fix channel admin permissions issue

* fix linter and fix snapshots

* allow non-sysadmin users to see the system policy information banner

* stack modals backdrops

* address pr feedback; reorganize function and add unit tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-11 18:27:30 +02:00
Alejandro García Montoro
c28d13cbc9
MM-64692: Migrate passwords to PBKDF2 (#33830)
* Add parser and hasher packages

The new `password` module includes two packages:
- `hashers` provides a structure allowing for seamless migrations
between password hashing methods. It also implements two password
hashers: bcrypt, which was the current hashing method, and PBKDF2, which
is the one we are migrating to.
- `parser` provides types and primitives to parse PHC[0] strings,
serving as the foundation of the `PasswordHasher` interface and
implementations, which are all PHC-based.

[0] https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md

* Use latest hasher to hash new passwords

The previous commit added a LatestHasher variable, that contains the
`PasswordHasher` currently in use. Here, we make sure we use it for
hashing new passwords, instead of the currently hardcoded bcrypt.

* Use errors from hashers' package

Some chore work to unify errors defined in `hashers`, not from external
packages like `bcrypt`.

* Implement password migration logic

This commit implements the actual logic to migrate passwords, which
can be summarized as:

0. When the user enters their password (either for login in
`App.CheckPasswordAndAllCriteria` or for double-checking the password
when the app needs additional confirmation for anything in
`App.DoubleCheckPassword`), this process is started.
1. The new `App.checkUserPassword` is called. In
`users.CheckUserPassword`, we parse the stored hashed password with the
new PHC parser and identify whether it was generated with the current
hashing method (PBKDF2). If it is, just verify the password as usual and
continue normally.
2. If not, start the migration calling `App.migratePassword`:
  a. First, we call `Users.MigratePassword`, which validates that the
  stored hash and the provided password match, using the hasher that
  generated the old hash.
  b. If the user-provided password matches the old hash, then we simply
  re-hash that password with our current hasher, the one in
  `hashers.LatestHasher`. If not, we fail.
  c. Back in `App.migratePassword`, if the migration was successful,
  then we update the user in the database with the newly generated hash.

* make i18n-extract

* Rename getDefaultHasher to getOriginalHasher

* Refactor App checkUserPsasword and migratePassword

Simplify the flow in these two methods, removing the similarly named
users.CheckUserPassword and users.MigratePassword, inlining the logic
needed in the App layer and at the same time removing the need to parse
the stored hash twice.

This implements a package-level function, CompareHashAndPassword: the
first step to unexport LatestHasher.

* Add a package level Hash method

This completely removes the need to expose LatestHasher, and lets us
also remove model.HashPassword, in favour of the new hashers.Hash

* Unexport LatestHasher

* Remove tests for removed functions

* Make the linter happy

* Remove error no longer used

* Allow for parameter migrations on the same hasher

Before this, we were only checking that the function ID of the stored
hash was the ID of the latest hashing method. Here, we no longer ignore
the parameters, so that if in the future we need to migrate to the same
hashing method with a different parameter (let's say PBKDF2 with work
factor 120,000 instead of work factor 60,000), we can do it by updating
the latestHasher variable. IsPHCValid will detect this change and force
a migration if needed.

* Document new functions

* make i18n-extract

* Fix typo in comment

Co-authored-by: Ben Cooke <benkcooke@gmail.com>

* Rename parser package to phcparser

* Simplify phcparser.New documentation

* Rename scanSymbol to scanSeparator

Redefine the list of separator tokens, including EOF as one.

* Document undocumented functions that are unexported

* Reorder error block in checkUserPassword

* Add unit tests for IsLatestHasher

* Reorder code in parser.go

* Enforce SHA256 as internal function for PBKDF2

* Fix typo in comment

Co-authored-by: Eva Sarafianou <eva.sarafianou@gmail.com>

---------

Co-authored-by: Ben Cooke <benkcooke@gmail.com>
Co-authored-by: Eva Sarafianou <eva.sarafianou@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-11 16:43:34 +02:00
Maria A Nunez
3253b9ff6d
Message History Limits in Entry Edition (#33831)
* Support for Entry license with limits + updates to Edition & License screen

* Refactor message history limit to use entry sku limits

* Fixed missing update on license change

* Fix typo in limit types

* Revert unnecessary thread change

* Revert merge issue

* Cleanup

* Fix CTAs of limit notifications

* Linting

* More linting

* Linting and fix tests

* More linting

* Fix tests

* PR feedback and fix tests

* Fix tests

* Fix test

* Fix test

* Linting

* Simplified Limit panels

* Linting

* PR feedback

* Revert back job time

* Linting

* linting

* Fixed issue switching in RHS

* PR Feedback

---------

Co-authored-by: Nick Misasi <nick.misasi@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-10 22:52:19 -04:00
Ben Schumacher
06a46f6080
Lower Job complete log message to debug (#33828) 2025-09-10 15:40:30 +02:00
Ben Schumacher
d78d59babe
Standardize request.CTX parameter naming to rctx (#33499)
* Standardize request.CTX parameter naming to rctx

- Migrate 886 request.CTX parameters across 147 files to use consistent 'rctx' naming
- Updated function signatures from 'c', 'ctx', and 'cancelContext' to 'rctx'
- Updated function bodies to reference the new parameter names
- Preserved underscore parameters unchanged as they are unused
- Fixed method receiver context issue in store.go

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Use request.CTX interface in batch worker

* Manual fixes

* Fix parameter naming

* Add linter check

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-10 15:11:32 +02:00
Ben Schumacher
9c8148a0a7
[MM-65127] Add Elasticsearch config testing to support packet diagnostics (#33782)
- Test Elasticsearch configuration when indexing is enabled
- Capture configuration errors in support packet diagnostics
- Add comprehensive test coverage for Elasticsearch scenarios
- Fix LDAP mock cleanup in existing tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-10 13:06:38 +02:00
Pablo Vélez
4542ecc9d4
Mm 65096 - channel admin rules confirmation modal (#33758)
* MM65096 - channel admin rules confirmation modal

* trigger the sync job directly

* update the active state correctly and adjust styling

* Add ids to policy search so sync job finds the channel policy

* combine the channel and the inherited policies expressions for confirm modal

* add missing translations

* fix tests and fix incorrect Id definition

* fix translations

* Revert "fix translations"

* fix typo

* remove plugin auto injected logging code

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-09 16:41:07 +02:00
Christopher Speller
ba86dfc587
Sanatize LastViewedAt and LastUpdateAt for other users on channel member object (#33835) 2025-09-05 08:06:16 -07:00
Jesse Hallam
8cace74692
MM-64486: Remove telemetry (#33606)
* MM-64486: Remove telemetry

Remove telemetry from Mattermost. We're no longer relying on Rudder upstream, and no longer making use of this information.

* recover mock for SystemStore.Get

* Fix TestClearPushNotificationSync by adding missing SystemStore mock

The test was failing because the SystemStore mock was missing the Get()
method that's required by the ServerId() function. Added the missing mock
to return a StringMap with SystemServerId.

* fix mocking issue

* Remove now-unused telemetry and constants

* Remove "Disable telemetry events" debug setting

* Remove empty functions

* Remove most "Telemetry tracking removed" comments

* Remove remains of DataPrefetch telemetry

* Remove now-unused prop from InviteMembersButton

* Remove trackDotMenuEvent

* Remove some more leftover comments

* Remove lingering logic related to trackingLocation

* Remove now-unused argument from useCopyText

* Remove lingering telemetry references from PreparingWorkspace

* fixup Remove trackDotMenuEvent

* Remove lingering telemetry references from signup page and password check

* Update snapshots and fix test broken by my changes

* Fix unintended behavior change in thread list filtering

Remove handleSetFilter wrapper that was accidentally modified during
telemetry removal. The function was calling clear() when switching to
unread filter, which was not the original behavior. Use setFilter
directly instead, restoring the original functionality.

* Remove unused useOpenDowngradeModal hook

The useOpenDowngradeModal hook was not being used anywhere in the codebase.

* Remove unused expandableLink from useExpandOverageUsersCheck

The expandableLink return value was not being used by any components.

* Re-add missing TeamLinkClicked performance telemetry

The mark(Mark.TeamLinkClicked) call was accidentally removed from the
handleSwitch function. This telemetry is needed for Looker-based
performance tracking.

* drop LogSettings.VerboseDiagnostics

---------

Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-04 18:46:18 +00:00
Rajat Dabade
d00cb6ba8b
Fixes an authentication loop bug where users with a valid MMAUTHTOKEN cookie but missing/invalid MMCSRF (#33668)
* Fixes an authentication loop bug where users with a valid MMAUTHTOKEN cookie but missing/invalid MMCSRF

* checkCSRFToken as pure function
2025-09-01 13:45:41 +05:30
Scott Bishel
abe8151bad
Add Dynamic Select for Interactive Dialog (#33586)
* Add AppsForm-based InteractiveDialog implementation with feature flag control

- Add InteractiveDialogAppsForm feature flag (default enabled) to control migration path
- Enhance AppsForm components with backwards compatibility features:
  - Add onHide prop support for legacy dialog behavior
  - Add RADIO field type support with proper rendering
  - Add required field indicators with red asterisk styling
  - Use FormattedMessage for "(optional)" text internationalization
- Create InteractiveDialogAdapter to bridge legacy dialogs to AppsForm:
  - Convert DialogElement fields to AppField format with proper type mapping
  - Handle default value conversion for select, radio, and boolean fields
  - Implement submission adapter to convert between Apps and legacy formats
  - Support cancel notifications and proper context creation
- Update InteractiveDialog container to route between implementations based on feature flag
- Add Redux selector for feature flag state management

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix circular dependency issue with dynamic InteractiveDialog import

Replace static import of InteractiveDialog in websocket_actions.jsx with
dynamic import to resolve circular dependency chain that was causing test
failures in unrelated components.

The static import created a dependency chain:
websocket_actions → InteractiveDialog → AppsFormContainer → AppsFormComponent
→ Markdown → AtMention → user group components

This affected many tests because websocket_actions is imported by core
system components. The dynamic import only loads InteractiveDialog when
the dialog event is actually triggered, improving performance and breaking
the circular dependency.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Refactor InteractiveDialog to use isolated DialogRouter architecture

Move InteractiveDialogAdapter out of the interactive_dialog directory to
break circular dependency chain that was causing test failures in unrelated
components.

**Changes:**
- Create new `dialog_router` component with dynamic imports for both legacy
  InteractiveDialog and AppsForm-based adapter
- Move InteractiveDialogAdapter to dialog_router directory to isolate it
  from existing components
- Update adapter to use dynamic import for AppsFormContainer to avoid
  circular dependency
- Replace embedded routing logic in interactive_dialog/index.tsx with
  clean DialogRouter usage

**Benefits:**
- Fixes circular dependency: websocket_actions → InteractiveDialog →
  AppsFormContainer → AppsFormComponent → Markdown → AtMention components
- Cleaner separation of concerns - new code is isolated from existing stable code
- Dynamic imports improve performance by loading components only when needed
- Maintains backward compatibility while enabling new AppsForm features

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* lint fixes

* Fix TypeScript compilation error in dropdown_input_hybrid

Explicitly constrain react-select types to single-select mode (isMulti=false)
to resolve type inference conflicts introduced by the InteractiveDialog to
AppsForm migration. The component was always single-select only, but the
types were previously ambiguous.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix ESLint errors in dropdown_input_hybrid

- Fix variable naming convention violation
- Add eslint-disable comment for intentionally unused components prop
- Ensures clean CI/CD pipeline

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Enhance InteractiveDialogAdapter with comprehensive validation and type safety

- Add enhanced TypeScript interfaces (ValidationError, ConversionContext)
- Implement comprehensive dialog and element validation with server-side limits
- Add XSS prevention through string sanitization for security
- Implement structured logging following Mattermost webapp conventions
- Maintain complete backwards compatibility (validation disabled by default)
- Add configurable validation modes (validateInputs, strictMode, enableDebugLogging)
- Enhance error handling with detailed field-specific validation
- Support all dialog element types with proper validation rules
- Add proper server-side length limits (title: 24, name: 300, etc.)
- Improve type safety throughout conversion logic

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix lint errors

* Fix test expectations for XSS sanitization in InteractiveDialogAdapter

- Update test assertions to match actual sanitization behavior
- Fix expected text content for script and iframe tag removal
- Correct event handler sanitization test expectations
- All 23 InteractiveDialogAdapter tests now pass successfully

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix ESLint errors in InteractiveDialogAdapter test file

- Replace await-in-loop with Promise.all for boolean conversion tests
- Add newline at end of file to satisfy eol-last rule
- All tests continue to pass (23/23)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix React act() warnings in apps_form_field tests

- Wrap async select field renders in act() to prevent console warnings
- Fix user, channel, and dynamic select field test warnings
- Add proper async/await handling for react-select components
- All 17 apps_form_field tests now pass without warnings

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Simplify default value handling to match original InteractiveDialog

- Remove complex numeric subtype logic - not needed
- Use simple `element.default ?? null` for all text/textarea fields
- Matches original InteractiveDialog behavior exactly (lines 42-50)
- Treat all field types consistently like original dialog
- Fix syntax error with missing brace in switch statement

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Enhance InteractiveDialogAdapter with server-side error handling and improved type safety

- Fix server-side submission failures to keep dialog open and display errors
- Add proper TypeScript types for ActionResult<SubmitDialogResponse>
- Implement comprehensive error handling for both server and network errors
- Add numeric field support with proper number conversion and fallback
- Enhance test coverage with server-side error handling scenarios
- Maintain backwards compatibility with existing InteractiveDialog behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add internationalization for InteractiveDialogAdapter error messages

- Replace hardcoded error strings with proper i18n using intl.formatMessage()
- Add new localization keys to server/i18n/en.json for user-facing error messages
- Support parameter interpolation for dynamic error details
- Maintain backwards compatibility with default English messages
- Follow Mattermost internationalization patterns and conventions

Error messages localized:
- interactive_dialog.submission_failed
- interactive_dialog.submission_failed_validation
- interactive_dialog.validation_failed
- interactive_dialog.element_validation_failed

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix i18n-extract

* remove dynamic loading, see if tests still fail

* Optimize InteractiveDialogAppsForm validation and performance

- Remove redundant validateDialogElement calls (50% validation performance improvement)
- Simplify DialogRouter by eliminating unnecessary async loading state
- Optimize option validation with combined loop for select/radio fields
- Fix TypeScript errors with proper PropsFromRedux type inheritance
- Replace regex stringMatching with traditional string patterns in tests
- Simplify mocked state in interactive_dialog.test.ts (1500+ lines → minimal)
- Fix ESLint issues: trailing spaces and import ordering

Performance improvements:
- DialogRouter: 50% faster mounting (eliminated loading state)
- Validation: 50% fewer validation calls per element
- Bundle: No size increase, better tree-shaking

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Convert all test files from enzyme to React Testing Library

- Replace enzyme shallow/mount with React Testing Library's renderWithContext
- Update all assertions to test user-visible behavior instead of implementation details
- Remove brittle snapshot test and replace with behavioral assertions
- Add comprehensive test coverage for form validation, lookup functionality, and edge cases
- Fix all ESLint and styling issues
- Remove unused enzyme imports and dependencies

This improves test maintainability and aligns with modern React testing best practices
by focusing on user interactions rather than component internals.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix all failing tests in apps_form_component.test.tsx

- Fix error message assertion to match exact text instead of regex
- Simplify lookup functionality tests to avoid async rendering issues
- Update custom submit buttons test to handle multiple cancel buttons correctly
- Remove complex field configurations that were causing React Select warnings
- All 27 tests now pass successfully

The tests are now more stable and focus on verifying component configuration
and user-visible behavior rather than complex async interactions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix lint

* cleanup tests, fix E2E tests

* Improve unit test coverage for InteractiveDialogAdapter and AppsForm components

• Add 22 new comprehensive test cases across both components
• interactive_dialog_adapter.test.tsx: Added 9 new tests covering advanced validation scenarios, enhanced type conversion, and error handling
• apps_form_component.test.tsx: Added 13 new tests covering component lifecycle, field error handling, client-side validation, and lookup functionality
• Enhanced coverage includes validation edge cases, error recovery, form state management, and component interaction patterns
• All tests passing: 49/49 for interactive_dialog_adapter and 50/50 for apps_form_component

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add submit_label backward compatibility for Interactive Dialog to AppsForm migration

This commit restores the submit_label functionality that was lost during the transition from Interactive Dialog to AppsForm. The changes ensure backward compatibility by allowing interactive dialogs to specify custom submit button text through the submit_label property.

Changes made:
- Added submit_label property to AppForm interface in apps.ts
- Updated InteractiveDialogAdapter to extract and pass through submitLabel from legacy dialogs
- Modified AppsForm component to use custom submit_label when provided instead of hardcoded "Submit"
- Added comprehensive test coverage for the new functionality
- Maintained XSS protection through existing sanitization methods

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update e2e tests for AppsForm compatibility and fix TypeScript compilation errors

This commit updates interactive dialog e2e tests to work with AppsForm instead of legacy interactive dialog:

Key changes:
- Update modal selectors from #interactiveDialogModal to #appsModal
- Update button selectors from #interactiveDialogSubmit to #appsModalSubmit
- Fix label selectors to work with AppsForm DOM structure
- Handle ReactSelect portal rendering for dropdown options
- Fix TypeScript compilation errors in demo_boolean_spec.ts with triple-slash references
- Add ESLint comment spacing fixes to interactive_dialog_adapter.test.tsx
- Update checkbox selectors to use generic input[type="checkbox"] instead of element IDs
- Remove feature flag disabling InteractiveDialogAppsForm to use AppsForm by default

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* updates from self review

* revert bad file commits

* Update files_1_spec.ts

* Add DYNAMIC_SELECT support for interactive dialogs

Implement comprehensive dynamic select functionality for interactive dialogs by leveraging the Apps framework, enabling real-time option loading via lookup API calls.

Server-side changes:
- Add DataSourceURL field to DialogElement model
- Add DialogSelectOption and LookupDialogResponse types
- Add IsValidLookupURL security validation function
- Add /api/v4/actions/dialogs/lookup endpoint with permission checks
- Add LookupInteractiveDialog app layer method for HTTP requests
- Support both dynamic_select type and select with data_source="dynamic"

Client-side changes:
- Add lookupInteractiveDialog Redux action and Client4 method
- Update InteractiveDialogAdapter with full lookup implementation
- Add URL resolution priority: data_source_url > call.path > dialog.url
- Add client-side URL validation and error handling
- Update TypeScript types and test mocks

Features:
- Real-time option loading as user types in dynamic select fields
- Security validation (HTTPS URLs and /plugins/ paths only)
- Backward compatible - existing dialogs work unchanged
- Two usage patterns supported for flexibility
- Graceful error handling with empty results fallback

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add comprehensive unit tests for DYNAMIC_SELECT support

This commit adds extensive test coverage for the DYNAMIC_SELECT feature
in interactive dialogs, ensuring reliability and maintainability.

Server Tests:
- API layer tests for /api/v4/actions/dialogs/lookup endpoint
- App layer tests for LookupInteractiveDialog functionality
- Model validation tests for DialogSelectOption and LookupDialogResponse
- URL security validation tests (HTTPS/plugin paths only)
- Client library implementation for LookupInteractiveDialog method

Webapp Tests:
- Interactive dialog adapter tests with 11 comprehensive test cases
- Dynamic select element conversion and rendering tests
- Lookup API call handling with proper request/response validation
- Error handling for failed lookups and network issues
- Security testing for URL validation and XSS prevention
- Value conversion between dialog and Apps Framework formats
- Empty response and edge case handling

All tests pass with proper linting and TypeScript compliance.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* remove dynamic_select and fix bug

* vet, i18n-extract

* fix tests

* fix lint

* fix translations

* fix tests

* fix tests, allow http:localhost and http:127.0.0.1

* fix tests, shorten display name

* initial fixes from reviews

* more review cleanup/fixes

* i18n-extract

* fix interactive dialog tests

* fix circular reference error in tests

* fix/cleanup tests

* lint fix

* use makeAsyncComponent instead of DynamicAppsFormContainer

* fix tests

* fixed missing action

* increase tests coverage

* lint, styles, test fixes

* lint, styles, test fixes

* fix tests

* mysql fixes

* tests fix

* Reset cypress.config.ts

* fix test

* Address review comments for interactive dialog dynamic select

- Update minimum server version from 8.0 to 11.0 in API documentation
- Add OOM protection using io.LimitReader with 1MB limits for dialog responses
- Remove redundant dynamic_select element type validation and tests
- Add shared MaxDialogResponseSize constant for consistency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* remove blank line

* s/bookwork/bullseye to preserve glibc < 2.34 (#33546)

With glibc 2.34 and the [removal of libpthread](https://developers.redhat.com/articles/2021/12/17/why-glibc-234-removed-libpthread), binaries built using [Debian bookworm](https://www.debian.org/releases/bookworm/) aren't compatible with older but still supported operating systems like RHEL8. In those environments, Mattermost fails to start with errors like:
```
mattermost/bin/mattermost: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by mattermost/bin/mattermost)
mattermost/bin/mattermost: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by mattermost/bin/mattermost)
```

One option might be to generate a static build and avoid the glibc dependency, but this kind of change is out of scope for now. Let's just revert back to using [Debian bullseye](https://www.debian.org/releases/bullseye/), which remains supported until at least August 2026.

* quick fix on typo (#33631)

* [MM-62991] Ensure extra content is also accounted for in the focus order (#33624)

* [MM-65015] Restore Mobile redirection on oauth login (#33626)

* Add comprehensive e2e tests for interactive dialog dynamic select feature

This commit implements complete end-to-end testing for dynamic select elements in interactive dialogs, including the necessary infrastructure and bug fixes to support the feature.

**Key Changes:**

- **E2E Test Suite**: Added `dynamic_select_spec.js` with comprehensive test coverage:
  - UI structure verification and accessibility checks
  - Dynamic search functionality with real-time filtering
  - Form submission and validation error handling
  - Keyboard navigation support
  - Edge cases (no matches, default values)

- **Webhook Infrastructure**: Enhanced test webhook server:
  - Added `/dynamic_select_dialog_request` and `/dynamic_select_source` endpoints
  - Implemented role-based search filtering with 12 predefined options
  - Fixed search parameter handling (`body.submission.query`)

- **Dialog Conversion Fix**: Updated `dialog_conversion.ts`:
  - Added missing `expand: {}` property to lookup objects for dynamic selects
  - Ensures proper AppCall format for createCallRequest compatibility

- **URL Validation Enhancement**: Modified `interactive_dialog_adapter.tsx`:
  - Allow HTTP localhost URLs for testing scenarios
  - Maintains security by restricting to localhost/127.0.0.1 only

**Test Coverage:**
- 7 comprehensive test scenarios covering all dynamic select functionality
- Tests validate UI, search, submission, validation, keyboard nav, and accessibility
- Proper handling of async operations and React-Select component interactions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix lint issue

* Fix trailing comma in dynamic select webhook response

Add trailing comma to items array in onDynamicSelectSource function
for consistent JavaScript formatting and better maintainability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Simplify IsValidLookupURL to follow existing model validation patterns

- Changed model-level validation to only check URL format (via IsValidHTTPURL)
- Security checks now happen at request time through existing DoActionRequest flow
- Aligns with patterns used by Commands, OutgoingWebhooks, and PostActions
- Configuration-based security validation (EnableInsecureOutgoingConnections, AllowedUntrustedInternalConnections) applied when lookup requests are made
- Updated tests to reflect new validation behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix styles

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Co-authored-by: sabril <5334504+saturninoabril@users.noreply.github.com>
Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
Co-authored-by: Guillermo Vayá <guillermo.vaya@mattermost.com>
2025-08-28 07:47:28 -06:00
Julien Tant
ec4a6235d4
MM-64518: Update Playbooks license requirements from Enterprise to Professional+ and unprepackage playbooks v1 (#31323)
* Remove TestPlaybooksLicenseChecking test function

Co-Authored-By: Claude <noreply@anthropic.com>

* fix test

* Remove playbooks v1 from prepackaged plugins

- Remove mattermost-plugin-playbooks-v1.41.1 from Makefile
- Remove license-based logic for choosing between playbooks v1/v2
- Remove obsolete test TestGetPrepackagedPlaybooksPluginIn
- Clean up transitionally prepackaged plugins logic
- Only ship playbooks v2.3.0 as regular prepackaged plugin

* Fix formatting with gofmt

* Fix linting issues

- Fix formatting in plugin_test.go
- Remove unnecessary blank line in plugin.go
- Use slices.Contains instead of manual loop

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-27 13:07:31 -07:00
Nick Misasi
0b7f66d7d7
[CLD-9487] Support for Entry + updates to Edition & License screen (#33672)
* Support for Entry license with limits + updates to Edition & License screen

* put back SetLicense(nil) for non FF enabled path

* Fix tests, add another

* Add changes

* Changes to address Figma adjustments

* Address PR feedback

* Shift entry license to enterprise, updates

* Update webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* More adjustments

* Remove Granular Administration

* Hide ABAC feature discovery on Entry

* PR feedback

* Update server/channels/app/platform/license.go

Co-authored-by: Julien Tant <785518+JulienTant@users.noreply.github.com>

* Fix tests

* fix tests properly

* Try to fix tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
Co-authored-by: Julien Tant <785518+JulienTant@users.noreply.github.com>
2025-08-27 10:05:39 -04:00
Eva Sarafianou
414fadb35c
Constant time comparison (#33588) 2025-08-27 14:17:16 +03:00
Harshil Sharma
22d0e66fbe
Data spillage card (#33646)
* WIP

* Added post flagging properties setup

* Added tests

* Removed error in app startup when content flaghging setup fails

* Updated sync condition:

* WIP

* MOved to data migration

* lint fix

* CI

* added new migration mocks

* Used setup for tests

* some comment

* removed empty files

* Added another property field

* WIP

* Updated test

* WIP

* Added card component

* WIP

* Displayed post preview

* WIP

* WIP

* Added team property:

* Adde post author field

* displayed post creation time

* WIP

* Added user selector

* refactored to use field sub types

* migration post types

* Added actions

* Added isRHS prop

* bvase finished

* Created separate single select

* Making common selector

* lint fixes

* i18n fixes

* cleanup

* fix: correct UserSelector mock import and props in test file

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

* fixed a test

* Added tests

* Added tests

* test: mock PostPreviewPropertyRenderer component in test file

* Fix tests

* Fix tests

* Stored version in system key

* test: add initial test file for use_team hook

* feat: add tests for useTeam hook based on usePost hook tests

* test: add useChannel hook test file

* feat: Add tests for useChannel hook

* test: add tests for DataSpillageAction component

* Handled dleted channel and team

* test: add comprehensive tests for ChannelPropertyRenderer

* Added ChannelPropertyRenderer tests

* test: add empty test file for post preview property renderer

* test: add comprehensive tests for PostPreviewPropertyRenderer

* test: update PostPreviewPropertyRenderer tests to use toBeVisible and assert content

* Added p[ost property renderer test

* test: remove PostMessagePreview mock and define base state for rendering

* Added p[ost property renderer test

* test: add test case for post with file attachments

* test: add assertions for file attachments visibility in post preview

* Added post property renderer test

* test: add empty test file for select property renderer

* test: add comprehensive tests for SelectPropertyRenderer

* Added base tests for select property renderer

* Added base tests for select property renderer

* test: add empty test file for team property renderer

* test: add comprehensive tests for TeamPropertyRenderer

* test: add assertion for TeamIcon rendering in TeamPropertyRenderer test

* test: use toBeVisible instead of toBeInTheDocument in team property renderer tests

* test: replace toBeInTheDocument with toBeVisible for team name assertion

* Added TeamPropertyRenderer tests

* test: add test file for text property renderer

* test: add comprehensive tests for TextPropertyRenderer

* Added TextPropertyRenderer tests

* test: add empty test file for timestamp property renderer

* test: add comprehensive tests for TimestampPropertyRenderer

* test: verify timestamp rendering with actual date and time values

* test: remove redundant test id visibility check in timestamp property renderer test

* feat: Add base state and test cases for 12 and 24 hour time formats

* Added TimestampPropertyRenderer tests

* test: add empty test file for user property renderer

* test: add comprehensive tests for UserPropertyRenderer

* WIP

* test: improve user property renderer test assertions

* Added UserPropertyRenderer tests

* test: add empty test file for propertyValueRenderer

* test: add comprehensive tests for PropertyValueRenderer with mocked components

* test: update text property rendering test assertion

* feat: add PropertyValue<null> type casting in test files

* Added PropertyValueRenderer test

* lint fix

* fixed tests

* refactor: Update ChannelNotificationsModal tests to remove snapshot testing and improve assertions

* refactor: replace fireEvent with userEvent in channel notifications modal tests

* Updated test to not use snapshots and use deep rendering

* refactor: Update DotMenu tests to use renderWithContext and userEvent

* Updating tests

* Updating tests

* Updating tests

* lint fix

* CI

* removed unused snapshots

* Updated text colot and removed hover color effect

* Lint fixes

* SCSS lint fix

* fixed a test

* Used useUser gook

---------

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>
2025-08-27 10:33:57 +05:30
Scott Bishel
9e0e1e9c93
MM-64943 Submit UserId and TeamId for DialogSubmission (#33617)
* ensure userId and teamId are always passed.

* revert changes to old InteractiveDialog

* lint fix

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-26 12:57:19 -06:00
Pablo Vélez
86c5c8a568
MM-64848 - extract actions to hook and implement table editor and test result modal (#33437)
* MM-6449 - manage channel access rules permissions backend part

* add the system console changes to show the new permission

* MM-64496 - update abac api permissions check

* fix unit tests

* enhance test coverage and fix broken unit tests

* fix linter issues

* add proper translations

* MM-64498 - create base code for channel settings modal

* Add feature flag to the channel admin abac rules

* fix unit tests

* remove unused translations

* add missing translation

* readd missing translations

* fix unit test after master merge

* fix linter issues

* migrate test to RTL

* MM-64848 - extract actions to hook and implement table editor and test result modal

* remove unnecessary comments and adjust catch logic

* adjust tests from enzyme to RTL

* expose abac config values to non system admin users

* add proper error on FF error

* fix unit tests

* add missing translation

* fix missing translation

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-26 11:30:41 +02:00
Alejandro García Montoro
553f99612e
MM-60441: Re-index public channels when a user joins a team (#33400)
* Index all public channels when a user joins a team

* Precompute team members for indexChannelsForTeam

* Refactor RequestContextWithMaster to store package

This way, we can import it from both the sqlstore and the searchlayer
packages. The alternative for this is duplicating the code in those two
packages, but that will *not* work:

The context package expects custom types for the keys stored in it, so
that different packages never clash with each other when trying to
register a new key. See the docs for the WithValue function:
https://pkg.go.dev/context#WithValue

If we try to duplicate the storeContextKey type in both the sqlstore and
searchlayer packages, although they *look* the same, they are not, and
HasMaster will fail to get the value of the storeContextKey(useMaster)
key if it's from the other package.

* Use master in call to GetTeamMembersForChannel

In GetTeamMembersForChannel, use the DB from the newly passed context,
which will be the receiving context everywhere except in the call done
from indexChannelsForTeam, to avoid the read after write issue when
saving a team member.

* Fix GetPublicChannelsForTeam paging

We were using the page and perPage arguments as is in the call to
GetPublicChannelsForTeam, but that function expects and offset and a
limit as understood by SQL. Although perPage and limit are
interchangeable, offset is not equal to page, but to page * perPage.

* Add a synchronous bulk indexer for Opensearch

* Implement Opensearch's SyncBulkIndexChannels

* Add a synchronous bulk indexer for Elasticsearch

* Implement Elasticsearch's SynkBulkIndexChannels

* Test SyncBulkIndexChannels

* make mocks

* Bulk index channels on indexChannelsForTeam

* Handle error from SyncBulkIndexChannels

* Fix style

* Revert indexChannelWithTeamMembers refactor

* Remove defensive code on sync bulk processor

* Revert "Add a synchronous bulk indexer for Opensearch"

This reverts commit bfe4671d96.

* Revert "Add a synchronous bulk indexer for Elasticsearch"

This reverts commit 6643ae3f30.

* Refactor bulk indexers with a common interface

* Test all the different implementations

Assisted by Claude

* Remove debug statements

* Refactor common code into _stop

* Rename getUserIDsFor{,Private}Channel

* Wrap error

* Make perPage a const

* Fix typos

* Call GetTeamsForUser only if needed

* Differentiate errors for sync/async processors

---------

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-25 19:28:19 +02:00
Miguel de la Cruz
ac3d087d2d
Adds admin managed property fields (#33662)
* Adds admin managed property fields

* Fix linter

* Adds extra tests

* Update server/public/model/custom_profile_attributes.go

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>

* Fix linter

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2025-08-22 12:33:20 +00:00
Pablo Vélez
bfa136e20e
Mm 64498 - create base code for channel settings modal (#32170)
* MM-6449 - manage channel access rules permissions backend part

* add the system console changes to show the new permission

* MM-64496 - update abac api permissions check

* fix unit tests

* enhance test coverage and fix broken unit tests

* fix linter issues

* add proper translations

* MM-64498 - create base code for channel settings modal

* Add feature flag to the channel admin abac rules

* fix unit tests

* remove unused translations

* add missing translation

* readd missing translations

* fix unit test after master merge

* fix linter issues

* migrate test to RTL

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-21 19:37:43 +02:00
Jesse Hallam
d4d8643e29
Remove certificate-based auth (#33751)
This feature has never worked as advertised. Let's deprecate it,
retaining the config field so we can fail server startup to ensure it's
not being used at all.
2025-08-21 09:59:20 -03:00
Henrique Machado
f418e1398d
[GH-28202]: Added GetGroupsByNames API (#33558)
* feat: Added GetGroupsByNames API
This commit implements the endpoint discussed in issue #28202.

This adds a new API endpoint to get multiple groups by a list of
names.

Previously, when the app received a post with @ mentions that it
didn't recognize, it would attempt to fetch them all as users,
then if some were still missing, it would go one by one attempting
to fetch each as a group. Now we just fetch all the groups at
once, just like we do for users.

Also added unit tests for the new API and it's respective
documentation.

* Added server version to GetGroupsByNames documentation

Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>

* fix: updated status_profile_polling tests to use new endpoint

* fix: fixed mock test

Was using get for post request

---------

Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
2025-08-20 18:20:07 -04:00
Pablo Vélez
6946aac2b3
MM-64496 - update abac api permissions check (#32134)
* MM-6449 - manage channel access rules permissions backend part

* add the system console changes to show the new permission

* MM-64496 - update abac api permissions check

* fix unit tests

* enhance test coverage and fix broken unit tests

* fix linter issues

* add proper translations

* fix unit tests

* remove unused translations

* add missing translation

* readd missing translations

* fix unit test after master merge

* Implement PR feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-21 00:10:10 +02:00
Jesse Hallam
dd11197043
MM-64807: Deprecate format parameter in client config endpoint (#33605)
* MM-64807: Deprecate format parameter in client config endpoint

- Remove requirement for format=old query parameter in /api/v4/config/client
- Endpoint now returns client configuration by default without parameters
- Maintain backward compatibility - format parameter is accepted but ignored
- Replace GetOldClientConfig with GetClientConfig across all clients
- Update API documentation to reflect simplified endpoint
- Update webapp client to remove format parameter usage

The endpoint previously returned HTTP 501 without format=old parameter.
Now it returns the client configuration directly, making the API more
intuitive while preserving compatibility with existing clients.

* Update i18n strings after format parameter deprecation

* Update E2E tests to use getClientConfig instead of getClientConfigOld

- Replace getClientConfigOld calls in playwright test library
- Aligns with format parameter deprecation in MM-64807

* Keep format=old parameter in webapp getClientConfig for pre-v11 compatibility
2025-08-20 12:15:11 -03:00
Pablo Vélez
6b4ff48bef
Mm 64925 - prevent slack import email auto validation for non admin users (#33609)
* MM-64925 - slack import issue autoverifying emails

* system admins imports auto verify emails

* pass just the isAdmin instead of the entire user struct

* enhance documentation and handle mattermost cmd import

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-20 17:13:01 +02:00
Ibrahim Serdar Acikgoz
0c828b1b32
[MM-64453] Guest shouldn't discover public channels that they are not member of (#31327) 2025-08-20 16:11:15 +02:00
Ibrahim Serdar Acikgoz
ff30b84049
[MM-64445] api4/channels_test: Add tests cases for guest user private channels (#31319) 2025-08-20 13:50:38 +02:00
Ben Schumacher
36b00d9bb6
[MM-64485] Remove separate notification log file (#33473)
- Remove NotificationLogSettings configuration entirely
- Add new notification-specific log levels (NotificationError, NotificationWarn, NotificationInfo, NotificationDebug, NotificationTrace)
- Consolidate all notification logs into standard mattermost.log file
- Update all notification logging code to use new multi-level logging (MlvlNotification*)
- Remove notification logger infrastructure and support packet integration
- Update test configurations and remove deprecated functionality tests
- Add comprehensive tests for new notification log levels

This change simplifies log analysis by unifying all application logging while maintaining flexibility through Advanced Logging configuration for administrators who need separate notification logs.

🤖 Generated with [Claude Code](https://claude.ai/code)
---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-20 10:17:45 +02:00
Harshil Sharma
bcfd7eff86
Post properties (#33395)
* WIP

* Added post flagging properties setup

* Added tests

* Removed error in app startup when content flaghging setup fails

* Updated sync condition:

* WIP

* MOved to data migration

* lint fix

* CI

* added new migration mocks

* Used setup for tests

* some comment

* removed empty files

* Added another property field

* WIP

* Updated test

* Stored version in system key

* fixed tests
2025-08-20 12:22:13 +05:30
Devin Binnie
4f06ab8379
[MM-64607] Add endpoint to check for upgradability, show correct error message and remove button if upgrade is not possible (#33528)
* [MM-64607] Add endpoint to check for upgradability, show correct error message and remove button if upgrade is not possible

* PR feedback

* PR feedback

* Fix test

* Fix tests again
2025-08-18 10:40:48 -04:00
Ben Schumacher
ac90cdbb97
[MM-63805] Don't throw a MFA warning for unauthenticated plugin requests (#30795)
* Don't throw a MFA warning for unauthenticated requests

* Always clean Authorization header

* Remove log message from GetSession

* Rewrite ServePluginPublicRequest for clarity

* Move CSRF validation into seperate method

* Update test

* linter

* Fix logger access

* Add log message if check fails

* Improve error messanges for internal errors

* linter fixes

* Add comprehensive tests

* Cleanup tests and token parser

* Add case-insensitive authentication header tests

Tests authentication with lowercase 'bearer' and uppercase 'TOKEN'
prefixes to ensure header parsing is case-insensitive.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* casing

* Update server/channels/app/plugin_requests.go

Co-authored-by: Eva Sarafianou <eva.sarafianou@gmail.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-18 11:17:33 +02:00
Jesse Hallam
c8d6630141
MM-63240: Always allow viewing archived channels (#32162)
* server: allow access to channel bookmarks in an archived channel

* server: allow access to posts in archived channels

* server: allow accessing channel members for archived channels

* server: allow autocompleting/searching archived channels

* server: allow access to files from archived channels

* server: fix access issue on database error

* server: allow access to archived channels

* server: remove TeamSettings.ExperimentalViewArchivedChannels from telemetry

* server: remove ExperimentalViewArchivedChannels from client config

* webapp: simplify delete channel

* webapp: simplify channel settings modal

* webapp: do not redirect away from archived channel

* webapp: rhs, always search posts from archived channels

* webapp: switch channels, always support archived channels

* webapp: search channel provider, always support archived channels

* webapp: browse channels, always support archived channels

* webapp, search results? fixup?

* webapp, confusing type issue

* webapp: unarchive, no need to report view archived

* webapp: command test, no need for ExperimentalViewArchivedChannels in config

* webapp: remove ExperimentalViewArchivedChannels from system console

* webapp: redux, do not delete posts, also fix LEAVE_CHANNEL

* update e2e tests

* server: fail startup if ExperimentalViewArchivedChannels is not enabled

* extract i18n

* updated snapshots

* update tests

* simplify posts reducer

* updated tests

* additional e2e tests

* Fix locale consistency in Jest tests

Added consistent locale environment variables (LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8)
to all Jest test scripts to prevent locale-dependent date formatting differences
across development environments.

This resolves snapshot test failures where DateTime.toLocaleString() would produce
different date formats on different systems (e.g., "6/8/2025" vs "08/06/2025" vs "2025-06-08").

Updated test scripts:
- test, test:watch, test:updatesnapshot, test:debug, test-ci

Updated snapshot to consistent en_US format.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove includeArchivedChannels parameter from GetMemberForPost

* Remove unnecessary includeDeleted variable assignments

* Deprecate ExperimentalViewArchivedChannels config field

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-08-15 13:50:20 -03:00
Ibrahim Serdar Acikgoz
8418572745
[MM-64795] Add multiple policy inheritance (#33583) 2025-08-12 13:15:00 +03:00
Devin Binnie
e8d7f94d97
[MM-64896][MM-64898] Pass inviteid/tokenid to relay state/props for external auth when auto-joining a team (#33545)
* [MM-64896][MM-64898] Pass inviteid/tokenid to relay state/props for external auth when auto-joining a team

* Check for group constraint when inviting by id
2025-08-08 08:57:29 -04:00
Guillermo Vayá
297385c114
[MM-65015] Restore Mobile redirection on oauth login (#33626) 2025-08-07 19:24:22 +02:00
David Krauser
c0ff672afb
[MM-64840] Add EmailNotificationWillBeSent Plugin Hook (#33421) 2025-08-05 09:09:07 -04:00
Ibrahim Serdar Acikgoz
b265672ce7
if the attributes do not exist, it means we should deny with 403 (#33411) 2025-08-05 12:05:13 +03:00
Jesse Hallam
9c57546fbc
Use a new Sentry key for v11+ (#33561)
This will allow us to eventually rotate out the older key and deprecate
reports from older Mattermost server versions.
2025-07-31 14:46:41 +00:00
Agniva De Sarker
41e88b74ac
MM-61407: Remove Bleve (#33430)
https://mattermost.atlassian.net/browse/MM-61407

```release-note
NONE
```

* webapp i18n

```release-note
NONE
```

* Fix e2e tests

```release-note
NONE
```

* fix roles in e2e tests

```release-note
NONE
```

* some review comments

```release-note
NONE
```

* add back permissions to deprecated list

```release-note
NONE
```
2025-07-31 09:35:29 +05:30
Devin Binnie
9d72bbfbd5
[MM-64911] Ensure redirect URL is validated before redirecting (#33559)
* [MM-64911] Ensure redirect URL is validated before redirecting

* PR feedback

* Fix nil check

* PR feedback

* PR feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-30 13:56:48 -04:00
Agniva De Sarker
b3d0fb6b1b
MM-64755: Fix redirect in oauth login (#33388)
https://mattermost.atlassian.net/browse/MM-64755

```release-note
NONE
```
2025-07-28 10:12:31 +05:30
Pablo Vélez
206c741226
Mm 64495 manage access rules permissions (#31658)
* MM-6449 - manage channel access rules permissions backend part

* add the system console changes to show the new permission

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-25 12:30:10 +02:00
Ben Schumacher
24bb82e345
[MM-63593] Add mmctl user edit command (#31181)
* Add mmctl user edit command

* Add e2e tests

* Use right client method to update authdata

* implement local API endpoint

* Don't allow users to clear the authdata

* make mmctl-docs

* Fix casing

* Fix example

* make mmctl-docs

* Simplify error message

* Fix test

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-25 09:56:25 +02:00
Agniva De Sarker
257eec43ed
MM-13657: Set ExperimentalStrictCSRFEnforcement to true by default (#33444)
https://mattermost.atlassian.net/browse/MM-13657
```release-note
We change ServiceSettings.ExperimentalStrictCSRFEnforcement to be
true by default for new installations. For existing installations,
the value will remain unchanged.
```

* Remove ''Experimental'' prefix from CSRF enforcement field

Change field name from ExperimentalStrictCSRFEnforcement to StrictCSRFEnforcement across all files

Co-authored-by: Agniva De Sarker <agnivade@users.noreply.github.com>

* lint fix

```release-note
NONE
```

* fix test

```release-note
NONE
```

* set StrictCSRFEnforcement to false on starting a test server

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Agniva De Sarker <agnivade@users.noreply.github.com>
Co-authored-by: Saturnino Abril <5334504+saturninoabril@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-24 13:51:29 +05:30
Jesse Hallam
415b793feb
fix spurious error log re: initializing Access Control (#33543) 2025-07-23 15:22:05 +00:00
Agniva De Sarker
0d048c79f8
MM-633368: Remove a new reference to MySQL (#33529)
This got in before I could merge the original PR.

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

```release-note
NONE
```
2025-07-22 15:44:51 +00:00
Agniva De Sarker
9dd8c056e7
MM-63368: Remove MySQL (#33458)
https://mattermost.atlassian.net/browse/MM-63368

```release-note
Remove MySQL support from the codebase entirely.
```
2025-07-22 20:40:55 +05:30
Ben Schumacher
53809e4500
Improve HTTP service IP and host validation error messages (#33450)
Co-authored-by: Nick Misasi <nick.misasi@mattermost.com>
2025-07-22 14:49:32 +02:00
Ben Schumacher
f16b040643
[MM-64858] Generate Support Packet in memory instead of writing it to the file store first (#33443)
Co-authored-by: Claude <noreply@anthropic.com>
2025-07-22 12:25:08 +02:00
Ben Schumacher
378af4cb74
Add comprehensive documentation for server/channels layers (#33449)
Added doc.go files for the three main layers of the Mattermost server architecture:

- api4/doc.go: HTTP REST API layer documentation
  - Explains endpoint structure and authentication handlers
  - Details input validation, permission checks, and error formatting
  - Covers security features and audit logging

- app/doc.go: Business logic layer documentation
  - Describes the core application logic components
  - Explains design patterns like request context and dependency injection
  - Details key responsibilities including data orchestration and event handling

- store/doc.go: Data persistence layer documentation
  - Documents the multi-layered architecture with caching, search, and retry layers
  - Explains the store interface pattern and domain-specific stores
  - Covers performance considerations and migration system

These documentation files provide comprehensive overviews of each layer's
responsibilities, architecture patterns, and integration points, making
the codebase more accessible to developers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-22 11:53:42 +02:00
Harshil Sharma
2f886a2ec1
Reporting config apis (#33378)
* Added enable/disable setting and feature flag

* added rest of notifgication settings

* Added backend for content flagging setting and populated notification values from server side defaults

* WIP user selector

* Added common reviewers UI

* Added additonal reviewers section

* WIP

* WIP

* Team table base

* Added search in teams

* Added search in teams

* Added additional settings section

* WIP

* Inbtegrated reviewers settings

* WIP

* WIP

* Added server side validation

* cleanup

* cleanup

* [skip ci]

* Some refactoring

* type fixes

* lint fix

* test: add content flagging settings test file

* test: add comprehensive unit tests for content flagging settings

* enhanced tests

* test: add test file for content flagging additional settings

* test: add comprehensive unit tests for ContentFlaggingAdditionalSettingsSection

* Added additoonal settings test

* test: add empty test file for team reviewers section

* test: add comprehensive unit tests for TeamReviewersSection component

* test: update tests to handle async data fetching in team reviewers section

* test: add empty test file for content reviewers component

* feat: add comprehensive unit tests for ContentFlaggingContentReviewers component

* Added ContentFlaggingContentReviewersContentFlaggingContentReviewers test

* test: add notification settings test file for content flagging

* test: add comprehensive unit tests for content flagging notification settings

* Added ContentFlaggingNotificationSettingsSection tests

* test: add user profile pill test file

* test: add comprehensive unit tests for UserProfilePill component

* refactor: Replace enzyme shallow with renderWithContext in user_profile_pill tests

* Added UserProfilePill tests

* test: add empty test file for content reviewers team option

* test: add comprehensive unit tests for TeamOptionComponent

* Added TeamOptionComponent tests

* test: add empty test file for reason_option component

* test: add comprehensive unit tests for ReasonOption component

* Added ReasonOption tests

* cleanup

* Fixed i18n error

* fixed e2e test lijnt issues

* Updated test cases

* Added snaoshot

* Updated snaoshot

* lint fix

* lint fix

* review fixes

* updated snapshot

* CI

* Added base APIs

* Fetched team status data on load and team switch

* WIP

* Review fixes

* wip

* WIP

* Removed an test, updated comment

* CI

* Added tests

* Added tests

* Lint fix

* Added API specs

* Fixed types

* CI fixes

* API tests

* lint fixes

* Set env variable so API routes are regiustered

* Test update

* term renaming and disabling API tests on MySQL

* typo

* Updated store type definition

* Minor tweaks

* Updated tests and docs

* finction rename

* Updated tests

* refactor

* lint fix

* Removed unnecesseery nil check

* Updated error code order in API docs
2025-07-22 14:57:37 +05:30
Agniva De Sarker
bc859d7fb0
MM-64522: Use PBKDF2 as the new key derivation for remote cluster invitation (#33493)
https://mattermost.atlassian.net/browse/MM-64522

```release-note
NONE
```
2025-07-21 19:08:31 +05:30
Ibrahim Serdar Acikgoz
d182c4f81f
fix select type being ignored when it's null (#33399) 2025-07-18 15:50:56 +02:00
Ben Schumacher
9add320011
[MM-64654] Migrate to modern Go features (#31820) 2025-07-18 12:54:51 +02:00
Jesse Hallam
1496d1ad99
Add URL validation to LinkMetadata cache and store (#31814)
* test hash collisions in link metadata

* guard against hash collisions in link metadata
2025-07-17 17:50:58 +02:00
Agniva De Sarker
d3f31299de
MM-64675: Enable modification of plugin settings in local mode (#33376)
The actual work needed for this ticket is already done.
Fixing some auxiliary things.

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

```release-note
NONE
```
2025-07-17 19:35:26 +05:30
Ben Schumacher
be0d4777ef
[MM-64320] Remove deprecated include_removed_members option in api/v4/ldap/sync (#31121) 2025-07-17 12:35:08 +02:00
Ben Schumacher
b7c2287ada
Move version logging to platform service initialization (#33431)
Co-authored-by: Claude <noreply@anthropic.com>
2025-07-16 22:22:11 +02:00
Vishal
dbc04cfebe
use consts for audit events (#33433) 2025-07-16 10:17:03 +05:30
Jesse Hallam
5c3a67b110
MM-62746: drop manual plugin deployment support (#30019)
We no longer support system administrators  manually unpacking plugins into the server's working directory for plugins. Instead, the server will be free to remove folders and files from this directory at will as it synchronizes installed plugins from the prepackaged cache and filestore.

Fixes: https://mattermost.atlassian.net/browse/MM-62746

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-16 01:46:41 +00:00
Nick Misasi
e402db875c
Add support for dynamic fetching of preview modal content from S3 bucket (#33380)
* Add support for dynamic fetching of preview modal content from S3 bucket

* Update server/channels/api4/cloud.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update webapp/channels/src/components/cloud_preview_modal/cloud_preview_modal_controller.test.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fixes for CI pipelines

* Add definitions for openapi spec

* Use any instead of interface{}

* Update translations

* Add the translations

* Hook should only run fetch when in cloud preview

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-15 12:58:18 -04:00
catalintomai
69e483f32b
MM-64531: [Shared Channels] Users on different remote servers should not communicate unless the remotes have established secure connection. (#30985) 2025-07-15 09:30:07 +02:00
catalintomai
c38f01c6a9
MM-62745: [Shared Channels] Fix duplicate mentioning - local user with the same username as someone on the remote server - Part2 (#32101)
* initial checkin

* remove some test methods

* remove debug statements

* simplify method

* simplify methods(1)

* simplify methods(2)
2025-07-14 14:57:22 +02:00
Agniva De Sarker
c4dde3d0ab
MM-64632: Fix a panic in bulk import (#33360)
We were incorrect de-referencing the channels slice
without checking for nil pointer first.

https://mattermost.atlassian.net/browse/MM-64632
```release-note
NONE
```
2025-07-09 09:37:36 +05:30
Harrison Healey
ad38971dd6
MM-64658 Fix handling of upload sessions (#32141)
* MM-64658 Fix handling of upload sessions

* Fix style issue
2025-07-08 16:46:00 +00:00
Harrison Healey
4b77485e8f
MM-64718 Improve validation of thread follower imports (#33287)
* MM-64718 Improve validation of thread follower imports

* Add additional test cases and restucture tests
2025-07-08 11:57:48 -04:00
Jesse Hallam
d2188ce1dd
remove spurious user limits log (#33038)
Only log a warning when the created user exceeds the `MaxUserLimits` if
`MaxUsersLimit > 0`. This was showing up spuriously on licensed servers
for which no limit applied.

Note that this is distinct from blocking user creation past
`MaxHardUsersLimit`.
2025-07-02 13:29:48 -03:00
Jesse Hallam
ebe03c1d45
Channel Store: No SELECT * (#32167)
* Replace SELECT * with explicit column lists in channel store

Migrates channel_store.go away from SELECT * patterns to explicit column
lists for better performance, maintainability, and schema safety.

- Replace GetPinnedPosts raw SQL with query builder using postSliceColumns()
- Replace "cc.*" in group channel search with channelSliceColumns()
- Replace GetChannelsBatchForIndexing raw SQL with query builder
- Replace channel member and team queries with respective column helpers
- Use SelectBuilder helper instead of manual ToSql() calls

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Replace SELECT * with COUNT(*) in user_test.go

Replaces unnecessary SELECT * queries with SELECT COUNT(*) in
TestPermanentDeleteUser bot count verification. Only needs to check
the count of bots, not retrieve full bot records.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-02 15:35:54 +00:00
Pablo Vélez
e99aa4e430
MM-64428 - user tag invite filtering (#31226)
* MM-64428 - user tag invite filtering

* fix lint issues

* remove unnecesary line

* update translations and skip mysql tests

* simplify the solution so in abac channels the invitation link is never shown

* finish clean up of unnecessary code

* clean up and remove no longer necessary translations

* remove leftover props and remove no longer needed tests after simplification

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-02 14:55:02 +02:00
Ibrahim Serdar Acikgoz
0809ce7a62
[MM-64630] Fix an issue where multiple channels can't be removed from policies (#32164)
* Fix an issue where multiple channels can't be removed from policies

* actually fix the issue

* use hardcoded limit

* simplify removal
2025-07-01 20:48:57 +02:00
Miguel de la Cruz
d8758f8984
Improve response on team restore (#32118)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-07-01 16:54:30 +00:00
Daniel Espino García
1b7d27707d
Fix MM64178 (#30957)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-30 16:43:59 -05:00
catalintomai
2b8f7743b6
MM-64687: Racy tests in TestSharedChannelPostMetadataSync (#32144) 2025-06-27 09:11:54 +02:00
Nick Misasi
9e7849647c
[CLD-9238] Direct preview user to proper team based on use case (#31784)
* Remove pricing modal. Adjust everywhere to instead open mattermost.com/pricing. When air gapped, don't show buttons to view plans.

* Fix lint

* Further clean up of unused code. Fixes for linter

* Remove onboarding tasklist for previews, add Cloud previer banner

* Fixes for linter, i18n

* Revert dev lines

* Fix lint

* When below one minute, switch to seconds

* fix linter

* Add scaffolding for new Cloud Preview Modal

* Style updates

* Fix tests

* fixes for PR feedback

* useExternalLink for opening pricing modal with enriched params

* Fix i17n

* fix style

* Fix style, tests

* Fix linter, types

* Add file

* Make types even more fixed

* fix: correct test case for SKU label not provided scenario

The test "should not render SKU label when not provided" was incorrectly using baseContent which includes a SKU label. Fixed by creating contentWithoutSku that explicitly sets skuLabel to undefined to properly test the scenario where no SKU label is provided.

Co-authored-by: Nick Misasi <nickmisasi@users.noreply.github.com>

* Fine I'll do it myself

* fix linter

* Refactors

* Adjustments from PR review. Adjustments to video experience (poster/play button) and starting to translate

* Fix i18n

* Accept use case in CWS login, redirect to proper team, with filtered content in preview modal

* Wrap translation strings with defineMessage for i18n extraction

- Add import for defineMessage and MessageDescriptor from react-intl
- Update type definition to use MessageDescriptor for better type safety  
- Wrap all skuLabel, title, and subtitle objects with defineMessage() calls
- This ensures the i18n-extract tool can properly detect translation strings

Co-authored-by: Nick Misasi <nickmisasi@users.noreply.github.com>

* Fix i18n

* Hiding modal will presist through refreshes

* Fix linter

* Add exception to notification permission bar for cloud previews

* Use regular modal close button

* Fix pipelines

* Fix i18n

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.tsx

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.tsx

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.tsx

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.tsx

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.tsx

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.tsx

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.tsx

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_controller.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Update webapp/channels/src/components/cloud_preview_modal/preview_modal_content.scss

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>

* Remove unnecessary CSS properties from preview modal content

Remove display: flex, height: 100%, and flex-direction: column from .preview-modal-content selector as they have no effect per code review feedback.

Co-authored-by: Nick Misasi <nickmisasi@users.noreply.github.com>

* feat: use getBool selector instead of get for boolean preference check

- Replace getPreference with getBool to avoid explicit === 'true' comparison
- Follows Harrison's review suggestion for cleaner boolean handling

Co-authored-by: Nick Misasi <nickmisasi@users.noreply.github.com>

* fix linter

* Fixes for PR review

* Fix linter

* Fix i18n

* fix linter

* Changes to address Harrison's feedback

* Change file name, remove index.tsx

* change file name, remove index.tsx

* Add the new files

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Nick Misasi <nickmisasi@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
2025-06-26 20:30:26 -04:00
Miguel de la Cruz
d042d242dd
Use master to fetch user profiles when creating a GM (#32152)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-06-26 13:47:29 +00:00
Miguel de la Cruz
0704500609
Update shared channel app layer to make active check optional (#29602)
The `getSharedChannelsService` method was checking as well for the
Shared Channels to be active, which only the lead node of a cluster
is, so API operations that should run correctly like sharing/unsharing
a channel or inviting/uninviting a remote were returning a 400 bad
request.

This change updates the method to check for the Shared Channel service
to be active only on request, and on doing so it changes the error and
status code returned to indicate specifically that the service is
running but inactive, and returns a 500 as the situation is not an
error on the requester.

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-26 10:54:17 +00:00
Miguel de la Cruz
d9a083dc82
Use master to get remotes to avoid race conditions in cloud (#31221)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-06-26 12:52:02 +02:00
David Krauser
aaa62a40ae
[MM-64686] Expose audit logging functionality via plugin API (#31204)
This commit exposes audit logging functionality to plugins via the plugin API, allowing plugins to create and log audit records. Additionally, it addresses a gob encoding issue that could cause plugin crashes when audit data contains nil pointers or unregistered types.
2025-06-25 20:37:32 -04:00
Christopher Poile
9b1e03a6b8
[MM-63557] mmctl: Add compliance export create cmd (#30594)
* Refactor job retrieval to support multiple statuses & multiple types

- Updated job retrieval functions to handle multiple job statuses.
- Renamed `GetJobsByTypeAndStatus` to `GetJobsByTypesAndStatuses` for consistency across the codebase.
- Adjusted related function signatures and implementations in the job store and retry layer to accommodate the new method.
- Updated tests to reflect changes in job retrieval logic and ensure proper functionality.

* Add compliance export create command and tests

- Introduced `ComplianceExportCreateCmd` to facilitate the creation of compliance export jobs with options for date, start, and end timestamps.
- Added unit tests for the new command, covering various scenarios including valid and invalid inputs.
- Updated documentation to include usage examples and options for the new command.
- Enhanced existing tests to ensure proper functionality of compliance export job handling.

* update docs

* update tests for new logic

* Refactor message export job tests to use DefaultPreviousJobPageSize

- Updated all test cases in worker_test.go to replace hardcoded page size of 100 with DefaultPreviousJobPageSize for consistency.
- Adjusted the worker.go file to define DefaultPreviousJobPageSize and use it in job retrieval logic.
- Ensured that the changes maintain the functionality of job data initialization and retrieval tests.

* PR comments

* PR comments, simplifications, clarifications, formatting

* prefer hypen over underscore in command names

* merge conflict

* update mmctl docs
2025-06-24 21:38:30 +00:00
Christopher Poile
b33a7e362f
[MM-63556] mmctl: Add compliance export download cmd (#30576)
* add mmctl compliance export download command and tests

- Introduced `ComplianceExportDownloadCmd` to facilitate downloading compliance export files.
- Implemented the `DownloadComplianceExport` method in the Client interface for handling file downloads.
- Added unit tests for the download command, covering successful downloads, error handling for non-existent jobs, and retries on failure.
- Included end-to-end tests to validate the command's functionality.
- Updated documentation to include usage examples and options for the new command.

* don't know why this was left out

* PR comments

* adjust test for new retry logic

* refactored download fn for compliance_export and export

* fix test due to fixed logic

* docs
2025-06-24 16:27:54 -04:00
Jesse Hallam
60a747f975
Always require signatures for prepackaged plugins (#31785)
* Always require signatures for prepackaged plugins

We have always required signatures for packages installed via the marketplace -- whether remotely satisfied, or sourced from the prepackaged plugin cache.

However, prepackaged plugins discovered and automatically installed on
startup did not require a valid signature. Since we already ship
signatures for all Mattermost-authored prepackaged plugins, it's easy to
simply start requiring this.

Distributions of Mattermost that bundle their own prepackaged plugins
will have to include their own signatures. This in turn requires
distributing and configuring Mattermost with a custom public key via
`PluginSettings.SignaturePublicKeyFiles`.

Note that this enhanced security is neutered with a deployment that uses
a file-based `config.json`, as any exploit that allows appending to the
prepackaged plugins cache probably also allows modifying `config.json`
to register a new public key. A [database-based
config](https://docs.mattermost.com/configure/configuration-in-your-database.html)
is recommended.

Finally, we already support an optional setting
`PluginSettings.RequirePluginSignature` to always require a plugin
signature, although this effectively disables plugin uploads and
requires extra effort to deploy the corresponding signature. In
environments where only prepackaged plugins are used, this setting is
ideal.

Fixes: https://mattermost.atlassian.net/browse/MM-64627

* setup dev key, expect no plugins if sig fails

* Fix shadow variable errors in test helpers

Pre-declare signaturePublicKey variable in loops to avoid shadowing
the outer err variable used in error handling.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Replace PrepackagedPlugin.Signature with SignaturePath for memory efficiency

- Changed PrepackagedPlugin struct to use SignaturePath string instead of Signature []byte
- Updated buildPrepackagedPlugin to use file descriptor instead of reading signature into memory
- Modified plugin installation and persistence to read from signature file paths
- Updated all tests to check SignaturePath instead of Signature field
- Removed unused bytes import from plugin.go

This change reduces memory usage by storing file paths instead of signature data
in memory while maintaining the same security verification functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-24 15:11:02 -03:00
Pablo Vélez
b3bc4b6f1b
Mm 64299 disable guest invite in abac channels (#31139)
* MM-64299 - disable guest invite in abac channels

* filter the abac channel list for guest

* add filter in the back-end too

* add proper translation

* simplify the condition for enforced channels and add the unit tests

* enhance validation for not inviting guest users when abac enforced channel

* add missing translation

* add value to empty translation

* prevent showing the channel name if abac protected
2025-06-23 18:17:55 +02:00
Pablo Vélez
5fc74cd401
MM-64330 - filter abac users in channel invite (#31219)
* MM-64330 - filter abac users in channel invite

* implement cursor functionality for abac user filtering

* remove unnecessary comments

* refactor the backend implementation simplifying the functions

* refactor api to use opts as parameters, rename function

* add missing translation

* remove unnecesary test code

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-20 10:53:14 +02:00
Jesse Hallam
968550d275
Fix undefined variable 'opts' in getSidebarCategoriesT function (#31815)
The function was trying to use 'opts.TeamID' but 'opts' was not defined in the function scope. Changed it to use the 'teamId' parameter which is properly defined in the function signature.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-20 01:27:28 +00:00
Jesse Hallam
dcc72c4c61
MM-63728: simplify category store with graphql gone (#30848)
* move category permissions to api

In https://github.com/mattermost/mattermost/pull/21038, we changed the
behaviour of the channel category store to filter out deleted teams and
teams for which the user was not a member. This was necessary in part
due to querying multiple teams via GraphQL.

With GraphQL no longer supported, let's move the permissions to the
API instead and remove the `JOIN` to filter out teams in the store.

Note that we /don't/ prevent access to deleted teams. For better or
worse, deleted teams remain largely accessible via other API endpoints
anyway.

* remove ExcludeTeam / GraphQL support

As part of https://github.com/mattermost/mattermost/pull/20353, we added
`ExcludeTeam` and the associated logic to support a GraphQL API.

With GraphQL no longer supported, let's simplify this logic and remove
the filtering and associated complexity.

* Fix shadow variable declaration in channel_store_categories.go

Fixed golangci-lint error by reusing existing err variable rather than shadowing it.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix build issue

* Remove SidebarCategorySearchOpts and simplify API to use teamID string

Per code review feedback, this change removes the SidebarCategorySearchOpts
struct entirely since the Type field was never used in the store implementation.
All methods now accept a simple teamID string parameter instead of the struct,
which simplifies the API and makes the code clearer.

Changes:
- Remove SidebarCategorySearchOpts struct from store.go
- Update CreateInitialSidebarCategories and GetSidebarCategories signatures
- Update all implementations (sqlstore, retrylayer, timerlayer, mocks)
- Update all callers to pass teamID string directly
- Clean up unused imports

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-20 00:48:12 +00:00
Harrison Healey
a3f60f797b
MM-63725 Populate multiple sidebar categories at once whenever possible (#31064)
* Remove redundant sidebar tests from TestChannelStore

* MM-63725 Refactor to split out getOrphanedSidebarChannels

* MM-63725 Populate multiple sidebar categories at once whenever possible

* Fix shadowing
2025-06-19 10:09:36 -04:00
Ben Schumacher
2661f77cea
[MM-64502] Fix errcheck linter errors in channel_test.go (#31309)
Co-authored-by: Claude <noreply@anthropic.com>
2025-06-19 14:13:45 +02:00
Ben Schumacher
cfc1503d62
[MM-63355] Add AuthData to mmctl user search output (#30478) 2025-06-19 11:52:16 +02:00
Ben Schumacher
04a60b6609
[MM-57693] Add schema dump to Support Packet (#31162)
Co-authored-by: Claude <noreply@anthropic.com>
2025-06-19 11:33:55 +02:00
Arya Khochare
824d3b8259
Fixed errcheck issues in server/channels/app/file_test.go (#28941)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-06-19 11:20:23 +02:00
catalintomai
bd5ca1c07e
MM-60640: [Shared Channels] Display remotes' names in Shared With tooltip (#30886) 2025-06-19 07:57:22 +02:00
catalintomai
c5f79bba09
MM-64610: Restrict import upload for shared channels feature. (#31659) 2025-06-18 15:49:58 +02:00
Jesse Hallam
e367872c0b
feat: Replace 5% grace period with configurable ExtraUsers field (#31629)
* feat: Replace 5% grace period with configurable ExtraUsers field

- Rename ExtraSeats to ExtraUsers in license Features struct
- Remove fixed 5% grace period and minimum 1 extra user logic
- Add configurable ExtraUsers field that allows exact control over additional seats
- Update calculateGraceLimit() to use extraUsers parameter directly
- When ExtraUsers is nil, defaults to 0 (hard cap with no overage)
- Special case maintained: zero user licenses always return 0 grace limit
- Update all tests to use new ExtraUsers functionality

Closes #31628

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* feat: eliminate calculateGraceLimit function, use inline baseLimit + extraUsers

- Remove calculateGraceLimit function and replace with inline calculation
- Allow extraUsers even when baseLimit is 0 (behavioral change)
- Update tests to reflect new behavior
- Remove TestCalculateGraceLimit since function no longer exists

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* feat: move ExtraUsers field to top level License struct

Move ExtraUsers field from Features struct to the top level License struct
for better organization and direct access. Update all references in limits.go
and limits_test.go to use the new field location.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* feat: use model.NewPointer for creating integer pointers in tests

Replace inline function declarations with model.NewPointer calls for cleaner code.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* feat: reorder ExtraUsers field to be after IsSeatCountEnforced

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* fix: format Go files with gofmt

- Remove extra blank line in limits.go
- Align struct fields in limits_test.go table test

Co-authored-by: Jesse Hallam &lt;lieut-data@users.noreply.github.com&gt;

* Fix user limits tests and document ExtraUsers field

- Fix TestCreateUserOrGuestSeatCountEnforcement to use ExtraUsers instead of old grace period
- Add documentation to ExtraUsers field explaining it as a grace mechanism
- Update test comments to reflect hard limit terminology

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-06-17 19:56:52 +00:00
Daniel Espino García
fc14fa0e87
Fix getAllChannels api not returning DMs/GMs (#31362)
Automatic Merge
2025-06-17 09:16:06 +03:00
Agniva De Sarker
761bc7549b
[AI assisted] MM-64298: Process setting status offline in batches (#31065)
When a user disconnects from the hub, we would spawn off a goroutine
which would make a cluster request, and then update the user status
as offline in the DB.

This was another case of unbounded concurrency where the number of
goroutines spawned was user controlled. Therefore, we would see
a clear spike in DB connections on master when a lot of users
would suddenly disconnect.

To fix this, we implement concurrency control in two areas:
1. In making the cluster request. We implement a counting semaphore
per-hub to avoid making unbounded cluster requests.
2. We use a buffered channel with a periodic flusher to process
status updates.

We also add a new store method to upsert multiple statuses
in a single query. The statusUpdateThreshold is set to 32, which means
no more than 32 rows will be upserted at one time, keeping the
SQL query load reasonable.

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

```release-note
We improve DB connection spikes on user disconnect
by processing status updates in batches.
```
2025-06-17 09:20:34 +05:30
Christopher Poile
548a47ae56
[MM-63152] LDAP Wizard (#31417)
* [MM-63717] LDAP Wizard skeleton (#31029)

* add ldap_wizard component to render its admin components

* i18n

* test adjustment

* keys and props fixes

* title fix

* fix placeholders

* fix value initialization

* linting

* remove all ...props (except custom component); any->unknown

* fix i18n (temp, will be changed in later PR)

* better return; simplify function checking/calling

* [MM-64259] Sections sidebar and navigation (#31059)

* initial sections list sidebar

* sidebar highlighting and scroll on click

* some tidying up

* add custom section titles for section sidebar

* i18n

* updating border on sections

* scss style lint

* color -> border-color

* simplify activeSectionKey initialization; remove trailing newline

* add useSectionNavigation; clean up ldap_wizard and scss; PR comments

* extract section of code into renderSidebar()

---------

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* [MM-64296] Add test connection for connection settings panel (#31190)

* button -> ldap test connect api

* fix console error by sanitizing value in text component

* return detailed error as error; adjust button -> primary, flushLeft

* middle of redesigning how we do hover text, first button

* add hover text to bools and file uploads

* i18n

* add LdapSettings as api type; add new endpoint to api yaml

* allow testing without first enabling LDAP and saving config

* i18n id changes

* improve TestLdapConnection to current standards

* PR comments

* safeDereference; cleaner returns

* remove hover markdown; formatting and typing simplification

* use button for "More Info"; i18n

* finish renaming help_text_hover -> help_text_more_info

* fix error output

* only send bindpassword if it has been changed

* fix: don't send blank bindPassword when it is still *****

* merge conflict

* [MM-64480] Refactor Admin Definition (#31280)

* move ldap definition to its own file for simplicity & context

* refactor admin_definition to eliminate circular dependencies

* merge conflicts

* before: buggy userHasReadPermissinOnSomeResources; after: fix incorrect snapshot

* merge conflict: new bindPasssword definition was left behind; fixed.

* merge conflict

* [MM-63765] LDAP Wizard: User filter expandable section (#31286)

* add "more info" hover to user filter help texts; make wider

* add expandable_setting type and component

* use Dislosure show/hide pattern for accessibility

* fix tooltip scss selectors

* fix hover -> more_info; make sure translation files are correct

* use join('\n\n') instead of the eslint disable line

* Revert "use join('\n\n') instead of the eslint disable line"

This reverts commit 274667e875b34703f14fee0706cd28b0125cefc9.

* [MM-64482] LDAP Wizard - Test User filters (#31312)

* initial cut at UI and backend for test filters

* api definitions; mocks

* clean up to current standards

* [MM-64512] - Test user filters UI (#31355)

* result_count -> total_count

* json cannot marshal error, returning error as string as god intended

* render errors with icon, hover text, and better feedback texts

* gather the settings that may be in expandable sections

* remove success, use error == "" to indicate success

* [MM-64536] LDAP Wizard: Test user attributes (#31373)

* LdapFilterTestResult -> LdapDiagnosticResult; FilterName -> TestName

* implement test_attributes endpoint and limited frontend (first step)

* adding EntriesWithValue

* [MM-64550] LDAP Wizard: Test user attributes UI (#31374)

* [MM-64551] LDAP Wizard: Test group attributes (#31375)

* remove Test LDAP button (not needed); reused helptext for other btn

* implement test_group_attributes endpoint; button/client-side paths

* [MM-64552] LDAP Wizard: Test group attributes UI (#31376)

* implement Test Group Attributes button

* simplify helper functions (improves useCallback dependencies)

* show the default filter that was used on the backend in the tooltip

* show the icon when there's an error (e.g. required filter/attribute)

* fix infinite rerendering

* fix error after failed save; fix navigation unlocked after save

* empty

* Adjust message feedback given we don't test the schema anymore

* improve css; don't use inline styles

* removed unneccesary pointer indirection

* improved i18n strings and logic

* combining filters/attributes/group attributes endpoints

improve types

* improve help text for User Filter (it's tricky)

* AvailableAttrs -> AvailableAttributes

* fix for e2e tests (renamed title)

* more e2e fixes

* skip broken e2e test

---------

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
2025-06-16 16:19:33 -04:00
catalintomai
ed3a6d6b91
MM-61033: [Shared Channels] Removing a shared channel on one end should make the other remove the shared channel too (#30738) 2025-06-16 16:25:00 +02:00
catalintomai
85391de22a
MM-57326: [Shared Channels] Message priority, acknowledgement and persistent notifications need to be synced (#30736) 2025-06-16 02:30:21 +02:00
catalintomai
fa1c77d9b0
MM-52600: [Shared Channels] Shared channels do not sync channel membership (#30976) 2025-06-15 10:07:56 +02:00
Jesse Hallam
0082e3e94d
enforce License.IsSeatCountEnforced if set (#31354)
* enforce License.IsSeatCountEnforced if set

If a license sets `IsSeatCountEnforced`, enforce the user limit therein
as a hard cap.

Fixes: https://mattermost.atlassian.net/browse/CLD-9260

* remove duplicate tests

* Improve user limit error messages and display

- Add separate error messages for licensed vs unlicensed servers
- Licensed servers: "Server exceeds maximum licensed users. ERROR_LICENSED_USERS_LIMITS"
- Unlicensed servers: "Server exceeds safe user limit. ERROR_SAFETY_LIMITS_EXCEEDED"
- Remove redundant "Contact administrator" text from activation errors shown to admins
- Fix system console to display actual server error messages instead of generic "Failed to activate user"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add license nil check and test coverage

- Add license != nil check in GetServerLimits to prevent panic
- Add test case to verify graceful handling of license being set to nil
- Ensures fallback to hard-coded limits when license becomes nil

Co-authored-by: lieut-data <lieut-data@users.noreply.github.com>

* Fix user limits tests to expect license-specific error IDs

Update test expectations to use the new license-specific error IDs:
- app.user.update_active.license_user_limit.exceeded for licensed server user activation
- api.user.create_user.license_user_limits.exceeded for licensed server user creation

Also update frontend to show actual server error messages instead of generic ones in system console.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove redundant license nil test

The test couldn't meaningfully verify nil license behavior since it relied on
hard-coded constants that can't be modified in the test.

Co-authored-by: lieut-data <lieut-data@users.noreply.github.com>

* Fix whitespace issue in limits_test.go

Remove unnecessary trailing newline to pass style checks.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* updated i18n

* s/ERROR_LICENSED_USERS_LIMITS/ERROR_LICENSED_USERS_LIMIT_EXCEEDED/, expand warning log

* Add 5% grace period for licensed user limits

- Add calculateGraceLimit() function with 5% or +1 minimum grace
- Apply grace period only to licensed servers with seat count enforcement
- Handle zero user licenses by returning zero grace limit
- Add comprehensive test coverage for grace period scenarios
- Unlicensed servers maintain existing hard-coded limits without grace

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix TestCreateUserOrGuestSeatCountEnforcement to account for 5% grace period

The test was failing because it expected user creation to fail at exactly
the license limit, but the implementation now includes a 5% grace period
before enforcement kicks in.

Changes:
- Update test cases to create users up to the grace limit (6 for a 5-user license)
- Add comments explaining the grace period calculation
- Both regular user and guest user creation tests now properly validate
  enforcement at the grace limit rather than the base license limit

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix TestUpdateActiveWithUserLimits to account for 5% grace period

Update test expectations to match the new grace period behavior:
- At base limit (100) but below grace limit (105): should succeed
- At grace limit (105): should fail
- Above grace limit (106): should fail

This aligns the tests with the license enforcement implementation
that includes a 5% grace period above the licensed user count.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: lieut-data <lieut-data@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-13 17:12:05 -03:00
catalintomai
c46ed6c681
MM-62751: [Shared Channels] Allow remote users to be discoverable in the create DM/GM modal (#30918) 2025-06-13 16:51:12 +02:00
Miguel de la Cruz
43018759e5
Adds support for GMs in shared channels (#31403)
* Adds support for GMs in shared channels

* Fix linter

* Remove creatorID from slack call

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-06-13 10:43:30 +00:00
Jesse Hallam
2ddb8e5d0a
Replace SELECT * with explicit column lists in sqlstore (#31356) 2025-06-11 18:16:05 -03:00
Devin Binnie
25a4839a9e
Automatic channel category sorting (#30866)
* Automatic channel category sorting

* Fix types

* AIed

* Fix issue where categories are updated for all users

* Move all logic to server, clean up

* PR feedback

* Fix lint

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-11 14:29:36 -04:00
Chris Gibson
5e3a89d70c
[GH-29960] Change behaviour for log messages that do not have a valid session (#30014)
Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-06-11 14:15:40 +02:00
Ibrahim Serdar Acikgoz
fcce46655a
Skip flaky test TestUnassignPoliciesFromChannels (#31380) 2025-06-11 12:45:22 +02:00
Julien Tant
731bd7c414
MM-63285: Add property field methods to plugin API (#31035)
Co-authored-by: Claude <noreply@anthropic.com>
2025-06-10 16:10:28 -07:00
Jesse Hallam
e6d8bf5835
Upgrade Go to 1.24.3 (#31220)
* Upgrade Go to 1.24.3

Updates the following files:
- server/.go-version: 1.23.9 → 1.24.3
- server/build/Dockerfile.buildenv: golang:1.23.9-bullseye → golang:1.24.3-bullseye
- server/go.mod: go 1.23.0 → go 1.24.3, toolchain go1.23.9 → go1.24.3
- server/public/go.mod: go 1.23.0 → go 1.24.3, toolchain go1.23.9 → go1.24.3

Also fixes non-constant format string errors introduced by Go 1.24.3's stricter format string checking:
- Added response() helper function in slashcommands/util.go for simple string responses
- Removed unused responsef() function from slashcommands/util.go
- Replaced responsef() with response() for translated strings that don't need formatting
- Fixed fmt.Errorf and fmt.Fprintf calls to use proper format verbs instead of string concatenation
- Updated marketplace buildURL to handle format strings conditionally

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update generated mocks for Go 1.24.3

Regenerated mocks using mockery v2.53.4 to ensure compatibility with Go 1.24.3.
This addresses mock generation failures that occurred with the Go upgrade.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update to bookworm and fix non-existent sha

Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>

* fix non-constant format string

---------

Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Stavros Foteinopoulos <stafot@gmail.com>
2025-06-10 15:04:57 -03:00
Harsh Aulakh
09a2037b61
MMCTL: Add import delete cmd for removing the import files (#29764)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-06-10 12:06:38 +02:00
Ben Schumacher
0cf6361139
[MM-63578] Fix support packet caching issue (#31133)
Fix support packet caching issue by adding no-cache headers

Added Cache-Control headers to prevent browser caching when downloading support packets.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-10 11:39:06 +02:00
Ben Cooke
aac34f6db4
[MM-64360] Data retention: optionally preserve pinned posts (#31165)
* add new config to preserve pinned posts during data retention

* more graceful error if the pinned post was a reply in a deleted thread
2025-06-09 15:41:07 -04:00
Christopher Poile
c0f1cbf727
[MM-64296] Help for AI: Respect env overrides for consoleLevel (#31278)
* respect env overrides for consoleLevel; add tests

* clean up test

* merge conflict

* improve parallelizability

* be better commenting

* better name for fn, comment explaining why we're using it

* empty

* empty

* empty

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-07 17:35:08 -04:00
Ben Schumacher
5b389c5224
[MM-63760] Only partially sanitize DB datasources for Support Packet (#30728)
Co-authored-by: Claude <noreply@anthropic.com>
2025-06-06 15:07:54 +02:00
Ben Schumacher
160cb91ab9
Fix error return value in Schedulers.scheduleJob (#31294) 2025-06-06 14:59:31 +02:00
Ben Schumacher
e3452dce94
[MM-29049] Fix remaining errcheck errors in app, api4 and web package (#31307)
Co-authored-by: Claude <noreply@anthropic.com>
2025-06-06 07:44:43 +02:00
Julien Tant
7e013f4c1a
Fix cross-team search from: filter not working (#31277)
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-05 11:53:35 -07:00
Ben Schumacher
924ed4ae02
Fix Support Packet v2 version number (#30723) 2025-06-05 20:07:31 +02:00
Akhil Bisht
4e337b9a43
MM-61450 fix errcheck issue in server/channel/app/permissions_test.go (#31132) 2025-06-05 19:43:40 +02:00
Ben Schumacher
50d81c2a38
Move cluser node specific files it thier own directories in Support Packet (#30755) 2025-06-05 07:58:34 +02:00
Nick Misasi
91862811f5
[CLD-9186] Remove onboarding tasklist, add preview banner (#31203)
* Remove pricing modal. Adjust everywhere to instead open mattermost.com/pricing. When air gapped, don't show buttons to view plans.

* Fix lint

* Further clean up of unused code. Fixes for linter

* Remove onboarding tasklist for previews, add Cloud previer banner

* Fixes for linter, i18n

* Revert dev lines

* Fix lint

* When below one minute, switch to seconds

* fix linter

* fixes for PR feedback

* useExternalLink for opening pricing modal with enriched params

* Fix i17n

* Fix style, tests

* Update webapp/channels/src/components/announcement_bar/cloud_preview_announcement_bar/index.tsx

Co-authored-by: Guillermo Vayá <guillermo.vaya@mattermost.com>

* Fix linter

---------

Co-authored-by: Guillermo Vayá <guillermo.vaya@mattermost.com>
2025-06-04 16:24:58 -04:00
Nick Misasi
0cacee570a
Remove in-product pricing modal (#31187)
* Remove pricing modal. Adjust everywhere to instead open mattermost.com/pricing. When air gapped, don't show buttons to view plans.

* Fix lint

* Further clean up of unused code. Fixes for linter

* fixes for PR feedback

* useExternalLink for opening pricing modal with enriched params

* Fix i17n

* Fix style, tests
2025-06-02 14:08:57 -04:00
Claudio Costa
d2292a13d2
Bump shared db pool size in store for parallel tests (#31262) 2025-06-02 09:59:21 +02:00
Ibrahim Serdar Acikgoz
6f26ad5cec
[ABAC - Table Editor] Improvements on table editor and review feedback (#31125)
* reflect review comments

* update table editor

* adjust test limits

* reflect review comments

* MM-64376

* resolve conflicts

* address review comments

* fix merge conflict error
2025-06-01 12:05:57 +02:00
Jesse Hallam
489ea1fdd6
Remove SELECT * from product notices store (#31246)
* Remove SELECT * from product notices store

Replace wildcard selects with explicit column names and use SelectBuilder pattern for consistency with other stores.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update server/channels/store/sqlstore/product_notices_store.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-31 14:53:42 +05:30
Jesse Hallam
86a2368fe0
avoid SELECT * in channel_store_categories.go (#31245) 2025-05-30 14:14:17 -05:00
Jesse Hallam
b7012952c4
MM-62158: Final migration for GetMemberUsersNotInChannel and GetMemberUsersInTeam (#31237)
* upgrade mattermost/squirrel

* migrate GetMemberUsersInTeam

* migrate GetMemberUsersNotInChannel
2025-05-30 16:20:05 +00:00
David Krauser
761584c040
[MM-64244] Add websocket disconnect reason metric (#31032)
We've recently spent some effort improving websocket reconnection logic. With this commit, I've augmented the websocket reconnect metric to include a disconnect reason. This will help us measure the impact of these changes in production.
2025-05-30 08:15:20 -04:00
Claudio Costa
611b2a8e79
[MM-62408] Server Code Coverage with Fully Parallel Tests (#30078)
* TestPool

* Store infra

* Store tests updates

* Bump maximum concurrent postgres connections

* More infra

* channels/jobs

* channels/app

* channels/api4

* Protect i18n from concurrent access

* Replace some use of os.Setenv

* Remove debug

* Lint fixes

* Fix more linting

* Fix test

* Remove use of Setenv in drafts tests

* Fix flaky TestWebHubCloseConnOnDBFail

* Fix merge

* [MM-62408] Add CI job to generate test coverage (#30284)

* Add CI job to generate test coverage

* Remove use of Setenv in drafts tests

* Fix flaky TestWebHubCloseConnOnDBFail

* Fix more Setenv usage

* Fix more potential flakyness

* Remove parallelism from flaky test

* Remove conflicting env var

* Fix

* Disable parallelism

* Test atomic covermode

* Disable parallelism

* Enable parallelism

* Add upload coverage step

* Fix codecov.yml

* Add codecov.yml

* Remove redundant workspace field

* Add Parallel() util methods and refactor

* Fix formatting

* More formatting fixes

* Fix reporting
2025-05-30 13:58:26 +02:00
Ibrahim Serdar Acikgoz
1cf2f08108
[MM-64437] Hotfix on attribute view creation error (#31225) 2025-05-30 11:35:31 +02:00
Devin Binnie
e1c0c57d31
[MM-63933] Don't include channels from an archived team unless specified in GetChannelsForUser (#31163)
* [MM-63933] Don't include channels from an archived team unless specified in GetChannelsForUser

* PR feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-29 13:35:38 +00:00
Daniel Espino García
293f38ad0b
Ensure users status is set to offline when deactivated (#30900) 2025-05-29 10:41:14 +02:00
Claudio Costa
d38c27f96f
[MM-64402] Improve validation of imported attachments (#31201)
* Improve validation of imported attachments

* Simplify multiple errors handling

* Improve logic

* Fix abs paths in tests

* Remove redundant clean

* Implement additional validation

* Fix absolute paths in test

* Add additional tests

---------

Co-authored-by: Lorenzo Gallegos <1328683+enzowritescode@users.noreply.github.com>
2025-05-29 07:44:50 +02:00
Harrison Healey
07239a5217
MM-64316 Fix icon_emoji not working on webhook posts (#31068)
* MM-64316 Fix icon_emoji not working on webhook posts

* Add test case for custom emojis

* Remove unneeded test cleanup

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-28 22:54:06 +00:00
Jesse Hallam
7a61d498ea
MM-64438: skip flaky: testGetNthRecentPostTime (#31223) 2025-05-28 17:47:43 -03:00
catalintomai
e6ed3436fb
MM-54023: [Shared Channels] Filter out system posts for channel update info that is not synced (#30735)
* initial checkin

* simplify tests, logic

* fix tests

* remove unneeded test

* fix spacing

* updates

* update logic

* fix logic

* move filtering to DB

* remove comment

---------

Co-authored-by: Catalin Tomai <catalintomai@catalins-macbook-pro-2.home>
2025-05-27 13:15:49 +00:00
Miguel de la Cruz
fbf105f6ef
Improves the invite mechanism for remote clusters (#31025)
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-05-27 13:39:13 +02:00
Miguel de la Cruz
e51ea025db
Deletes CPA values on CPA field type change (#31122)
* Deletes CPA values on CPA field type change

* Fix error method name reference

* Cleans the state when a CPA field's type is updated

* Fix types

* Fix linter

* Webapp no longer makes a decision on the change and server sents a flag in the WS message

* Fix linter

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-05-27 13:38:05 +02:00
Jesse Hallam
70a42ffd5f
Reject mysql for enterprise advanced (#31164)
* reject MySQL with the enterprise advanced license

If a user attempts to set an Enterprise Advanced License while
configured with MySQL, reject the license. This SKU is not compatible
with MYSQL.

* fix trial typo

* suppress trial banner if MySQL

* Update server/channels/app/platform/license_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix types

* suppress mysql from show start trial modal

* Skip MySQL-incompatible tests for access control and channel banner features

Skip the following tests when running with MySQL database:
- Access control policy tests (create, get, delete, check/test expressions, search, assign/unassign, get channels)
- Channel banner tests in TestPatchChannel and TestCanEditChannelBanner

These features are not supported on MySQL and the tests would fail.
Tests will continue to run normally on PostgreSQL.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Skip TestSearchChannelsForAccessControlPolicy subtest for MySQL

Add MySQL skip logic to the "SearchChannelsForAccessControlPolicy with regular user"
subtest as this access control feature is not supported on MySQL.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* reject trial license requests for MySQL

* return false on sku + mysql match, even if logger is nil

* Fix MySQL trial license tests to skip appropriately based on database driver

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-05-26 15:44:32 -03:00
Ben Cooke
bfe90c3704
New pluginapi method for syncables (#30790)
* new pluginapi method for syncables
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-21 14:44:34 -04:00
Jesse Hallam
31a8047973
Disable morph logging during TestMain (#30948)
* rm "No TEST_DATABASE... override" log message

Let's only log if this value is actually overridden.

* rm "(Created|Dropped) temporary database" message

* only log "Pinging SQL" on subsequent attempts

* disable morph logging from TestMain

* Fix style issues in store test files

- Add missing parameter to migrate() function calls in tests
- Remove unused log function in settings.go
- Fix formatting with go fmt

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* within sqlstore, use "enable" vs "disable" for clarity

* remove trailing newline from morph logs

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-05-21 17:31:18 +00:00
Jesse Hallam
92db356484
MM-62158: group store no select star, part3 (#30927)
* migrate getGroupsAssociatedToChannelsByTeam

* migrate GetGroups

* migrate teamMembersMinusGroupMembersQuery

* migrate channelMembersMinusGroupMembersQuery
2025-05-21 14:19:38 -03:00
Ben Schumacher
6de3379994
[MM-61099] Fix errcheck issues in server/channels/app/brand.go (#30679)
* [MM-28779] Fix errcheck issues in server/channels/app/brand.go

Remove brand.go from the errcheck exclusion list in .golangci.yml and fixed the error by properly handling the return value from a.MoveFile().

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [MM-28779] Add test to verify brand image backup functionality

Add a new test that verifies backup of the original brand image happens when a new one is uploaded. This helps to ensure the fix for errcheck issues is working as expected.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* use seperate temporary filestore for each test

* Use FileSettings.Directory instead of finding the dir programatically

* Fix another test

* Fix defer

* Update server/channels/api4/job_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix bad bot commit

* Cleanup logs message

* cleanup file path

* Fix error variable names

* WIP:cleanup panic ussage

* Revert "WIP:cleanup panic ussage"

This reverts commit c3284e4427.

* cleanup error checks

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-21 16:35:00 +02:00
Agniva De Sarker
09ea32a03c
MM-63300: Fix flaky test TestBusySet (#31116)
(*Busy).Set would set its own timer, and additionally
send a message across the cluster. In this case, the cluster
is mocked locally. But the timer calculation happens again.

We marshal the expiry time with b.expires.Unix() and send that
as part of model.ServerBusyState. This is parsed again in
ClusterEventChanged and converted to duration with time.Until.

Therefore, if it takes longer for the code to reach those lines,
then the new time calculated would have already expired, failing
the test.

To fix this, we increase the timeout. This slows down the test
at the cost of extra reliability. This is a common failure point
with any timer related tests.

Additionally, we also change the condition in compareBusyState
to check for less-than rather than strict equality.

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

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-21 08:48:46 +05:30
Agniva De Sarker
ad56ab3fdc
MM-62365: Remove unused field from MetricSample (#30991)
The Timestamp field was not used at all. Therefore
removing it.

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

```release-note
NONE
```
2025-05-21 08:43:00 +05:30
Harrison Healey
1bfd3a6a6e
Slightly improve performance of sidebar update APIs (#31061) 2025-05-20 21:16:28 +00:00
Harrison Healey
b70f1d859d
MM-63923/MM-63924/MM-63925 Prevent deadlocks and constraint errors in UpdateSidebarCategories (#30965)
* MM-63925 Remove most nested transactions from channel_store_categories.go

There's one place which still has a nested transaction in
CreateInitialSidebarCategories, but that's because it's calling out to a
different part of the store. The only way to avoid that would be to
break the extraction like UpdateSidebarCategories does to update
preferences, but I chose not to follow that pattern here and leave it
as-is.

* MM-63923 Prevent deadlocks caused by updating multiple categories in a different order

* MM-63923 Prevent deadlocks while deleting from SidebarChannels

This could also have been resolved by sorting the categories, but
combining the queries seems a bit more elegant.

* MM-63924 Ensure adding SidebarChannels rows is idempotent

* Add additional test to cause deadlocks

* Prevent channels from appearing in a single category multiple times

* Other review feedback
2025-05-20 16:02:32 -04:00
Jesse Hallam
fa40a8c5d4
MM-64226: improved post deduplication (#31004)
Require access to a post before allowing PendingPostId to deduplicate.

Fixes: https://mattermost.atlassian.net/browse/MM-64226
2025-05-20 10:05:10 -03:00
Ben Schumacher
c2d08b7540
[MM-63772] Add LDAP setting to re-add removed members (#30787) 2025-05-20 11:15:25 +02:00
Arya Khochare
f54d5b41c1
[MM-58163] Jobs paging/offset refactor (#30343)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-05-19 12:31:25 +02:00
Ibrahim Serdar Acikgoz
a344b3225b
[MM-61756] Attribute Based Access Control - Phase 1 (#30785)
Attribute Based Access Control - Base
* MM-63662

* MM-63919

* MM-63954

* MM-63955 

* MM-63425

* MM-63426

* MM-63458

* MM-63459

* MM-63603

* MM-63845

* MM-64146

* MM-64199

* MM-64201

* MM-64233

* MM-64247

* MM-64268

---------

Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
Co-authored-by: Pablo Andrés Vélez Vidal <pablovv2012@gmail.com>
Co-authored-by: abhijit-singh <abhijitsingh0702@gmail.com>
Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
2025-05-15 11:33:08 +02:00
Ben Cooke
1634b57dbd
fix flaky test (#31046) 2025-05-14 14:07:08 -04:00
Ben Cooke
6b4ab0a891
[MM-63774] Allow users to leave private channels when there is only 1 member (#30746)
* allow last user to leave private channel
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-14 11:58:13 -04:00
Jesse Hallam
d80d575f6c
MM-63619: improve Groups API error semantics (#30961)
Instead of 5xx errors, return `http.StatusInvalidRequest` when
adding or deleting invalid user ids from groups.

Fixes: https://mattermost.atlassian.net/browse/MM-63619
2025-05-14 10:17:30 -03:00
Miguel de la Cruz
6ab6a008e6
Adds the capability to retrieve a property field by name (#30859)
* Adds the capability to retrieve a property field by name

Allows to retrieve a property field by name and groupID. As the name
is only unique within the context of a group, and we can have multiple
fields with the same name in the store, for this method the groupID is
directly included in the query instead of being an optional field.

* Adds the targetID parameter to correctly filter fields

* Ensure the method only retrieves non-deleted fields

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-13 12:45:35 +02:00
Pablo Vélez
64ed8f02dc
MM-63912 - enhance validation for channel banner colors (#30981)
* MM-63912 - enhance validation for channel banner colors

* fix tests

* fix unit tests
2025-05-13 09:59:31 +02:00
Ben Cooke
b6b0c269c4
Use error from OnSamlLogin (#30745) 2025-05-12 18:41:54 -04:00
Jesse Hallam
f302b9844e
migrate groupsBySyncableBaseQuery (#30926) 2025-05-12 15:03:02 -03:00
Nick Misasi
cf2702f5dd
Pass the server's version in trial request payload (#30911)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-12 13:40:45 -04:00
David Krauser
4b64eb0e39
Handle error returned by GetClusterInfos() (#30919)
A recent change to the enterprise cluster code introduced a change to the enterprise API interface. GetClusterInfos() can now return an error. This commit introduces code to handle that error.
2025-05-12 13:37:58 -04:00
Agniva De Sarker
4803892492
MM-56906: Remove redundant calls on team switch (#30771)
On page load, we load ALL channels and channel members from all teams.
But then, on team_switch, we would again load channels and channel
members from that team. This was redundant and mainly kept
because previously the websocket events were considered unreliable.

Now with reliable websockets, and client-side pings, we can detect
broken connections faster and recover without loss.

Additionally, the getAllChannelMembers call would page through
all responses on the client side. This was inefficient and incur
extra latency. To optimize for this, we introduce server-side
streaming of the full response if page is set to -1.

This optimizes the intial response as well.

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

```release-note
Optimize team switch operation by removing calls to get channels
and channel members.
```


Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-12 20:05:46 +05:30
Ben Schumacher
bb8aabc15e
[MM-61765] Fix errcheck issues in server/channels/app/platform/license.go (#30954)
* [MM-61765] Fix errcheck issues in server/channels/app/platform/license.go

- Removed the errcheck exception for license.go from .golangci.yml
- Added proper error handling for RemoveLicense() calls
- Added proper error handling for ReloadConfig() and InvalidateAllCaches() calls
- Updated variable names to avoid conflicts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* simplify naming

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-05-12 13:41:59 +02:00
Ben Schumacher
4dbff921ba
[MM-61499] Fix errcheck issues in server/channels/app/slashcommands/helper_test.go (#30880) 2025-05-12 11:20:14 +02:00
Agniva De Sarker
509b8e9af7
MM-63130: Move to webHub iteration to be alloc-free (#30792)
We switch to using iterators introduced in Go 1.23
to make iteration alloc-free and fast. And since
element removal is allowed while iterating a map,
this also means we don't need to even copy the slice
any more.

While here, we also address the comment https://github.com/mattermost/mattermost/pull/30178#discussion_r1954862151.
I have simply gone back to using []string as the map
entry rather than a type alias or a redirection with
a struct.

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

```release-note
NONE
```

* Changed back nil to len

```release-note
NONE
```

* fixing unused assignment

```release-note
NONE
```

* add benchmark

```
goos: linux
goarch: amd64
pkg: github.com/mattermost/mattermost/server/v8/channels/app/platform
cpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
                               │   old.txt    │               new.txt               │
                               │    sec/op    │   sec/op     vs base                │
HubConnIndexIterator/2_users-8    93.53n ± 1%   38.09n ± 1%  -59.27% (p=0.000 n=10)
HubConnIndexIterator/3_users-8   106.30n ± 0%   38.41n ± 1%  -63.86% (p=0.000 n=10)
HubConnIndexIterator/4_users-8   111.30n ± 1%   38.66n ± 1%  -65.27% (p=0.000 n=10)
geomean                           103.4n        38.39n       -62.89%

                               │  old.txt   │               new.txt                │
                               │    B/op    │    B/op     vs base                  │
HubConnIndexIterator/2_users-8   16.00 ± 0%   24.00 ± 0%  +50.00% (p=0.000 n=10)
HubConnIndexIterator/3_users-8   24.00 ± 0%   24.00 ± 0%        ~ (p=1.000 n=10) ¹
HubConnIndexIterator/4_users-8   32.00 ± 0%   24.00 ± 0%  -25.00% (p=0.000 n=10)
geomean                          23.08        24.00        +4.00%
¹ all samples are equal

                               │  old.txt   │               new.txt               │
                               │ allocs/op  │ allocs/op   vs base                 │
HubConnIndexIterator/2_users-8   1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
HubConnIndexIterator/3_users-8   1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
HubConnIndexIterator/4_users-8   1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                          1.000        1.000       +0.00%
¹ all samples are equal
```

```release-note
NONE
```

* ForChannel test as well

```release-note
NONE
```

* review comments

```release-note
NONE
```

* fix lint errors

```release-note
NONE
```

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-11 12:00:12 +05:30
Ben Schumacher
cd3046773e
[MM-61498] Fix errcheck issues in server/channels/app/slashcommands/command_test.go (#30879)
Co-authored-by: Claude <noreply@anthropic.com>
2025-05-09 13:56:35 +02:00
Agniva De Sarker
0ebd3e8085
MM-64209: Optimize completePopulatingCategoryChannelsT for MySQL (#30963)
For our MySQL customers, we have discovered that the query is not
able to choose the right plan by itself without adequate hints.

This is only for MySQL as we have confirmed from multiple customers
that Postgres takes the right index idx_sidebarcategories_userid_teamid
for the sidebarCategories table. And if it doesn't, then a VACUUM ANALYZE
fixes it.

But for MySQL, we have to do two things:
- Pass an index hint to let it use idx_sidebarcategories_userid_teamid.
- Pass an optimizer hint to materialize the sub-query. This is used
to materialize the doesNotHaveSidebarChannel sub-query into a temporary
table, letting MySQL reuse the contents of the table for further processing
in the parent sections of the query.

I have confirmed both locally and in the customer environment
that it gives a clear benefit.

*LOCAL*

OLD:
```
| -> Nested loop antijoin  (cost=2889.85 rows=19767) (actual time=3.355..38.033 rows=15 loops=1)
    -> Nested loop inner join  (cost=66.65 rows=110) (actual time=0.410..1.689 rows=220 loops=1)
        -> Filter: ((Channels.DeleteAt = 0) and (Channels.`Type` in ('O','P')))  (cost=25.25 rows=110) (actual time=0.394..0.886 rows=220 loops=1)
            -> Index lookup on Channels using idx_channels_team_id_display_name (TeamId='team01'), with index condition: (Channels.Id is not null)  (cost=25.25 rows=220) (actual time=0.389..0.793 rows=220 loops=1)
        -> Single-row covering index lookup on ChannelMembers using PRIMARY (ChannelId=Channels.Id, UserId='user000')  (cost=0.28 rows=1) (actual time=0.003..0.003 rows=1 loops=220)
    -> Nested loop inner join  (cost=4967.50 rows=180) (actual time=0.165..0.165 rows=1 loops=220)
        -> Covering index lookup on SidebarChannels using PRIMARY (ChannelId=Channels.Id)  (cost=7.86 rows=180) (actual time=0.055..0.062 rows=13 loops=220)
        -> Filter: ((SidebarCategories.TeamId = 'team01') and (SidebarCategories.UserId = 'user000'))  (cost=44.93 rows=1) (actual time=0.008..0.008 rows=0 loops=2881)
            -> Single-row index lookup on SidebarCategories using PRIMARY (Id=SidebarChannels.CategoryId)  (cost=44.93 rows=1) (actual time=0.006..0.006 rows=1 loops=2881)
 |
```

NEW:
```
 | -> Nested loop antijoin  (cost=5879.73 rows=58021) (actual time=1.544..3.135 rows=15 loops=1)
    -> Nested loop inner join  (cost=66.65 rows=110) (actual time=0.421..1.778 rows=220 loops=1)
        -> Filter: ((Channels.DeleteAt = 0) and (Channels.`Type` in ('O','P')))  (cost=25.25 rows=110) (actual time=0.405..0.945 rows=220 loops=1)
            -> Index lookup on Channels using idx_channels_team_id_display_name (TeamId='team01'), with index condition: (Channels.Id is not null)  (cost=25.25 rows=220) (actual time=0.400..0.859 rows=220 loops=1)
        -> Single-row covering index lookup on ChannelMembers using PRIMARY (ChannelId=Channels.Id, UserId='user000')  (cost=0.28 rows=1) (actual time=0.003..0.004 rows=1 loops=220)
    -> Single-row index lookup on <subquery2> using <auto_distinct_key> (ChannelId=Channels.Id)  (cost=130.37..130.37 rows=1) (actual time=0.006..0.006 rows=1 loops=220)
        -> Materialize with deduplication  (cost=130.35..130.35 rows=527) (actual time=1.118..1.118 rows=205 loops=1)
            -> Filter: (SidebarChannels.ChannelId is not null)  (cost=77.61 rows=527) (actual time=0.059..0.851 rows=523 loops=1)
                -> Nested loop inner join  (cost=77.61 rows=527) (actual time=0.058..0.786 rows=523 loops=1)
                    -> Covering index lookup on SidebarCategories using idx_sidebarcategories_userid_teamid (UserId='user000', TeamId='team01')  (cost=2.81 rows=15) (actual time=0.025..0.031 rows=15 loops=1)
                    -> Covering index lookup on SidebarChannels using idx_sidebarchannels_categoryid (CategoryId=SidebarCategories.Id)  (cost=1.70 rows=35) (actual time=0.032..0.046 rows=35 loops=15)
```

Performance improvement from 38ms to 3ms.

*CUSTOMER ENV* (with sensitive data wiped off)

OLD:
```
| -> Sort: channels.DisplayName  (actual time=512..512 rows=5 loops=1)
    -> Stream results  (cost=3.28 rows=1.44) (actual time=223..512 rows=5 loops=1)
        -> Nested loop antijoin  (cost=3.28 rows=1.44) (actual time=223..512 rows=5 loops=1)
            -> Nested loop inner join  (cost=3.02 rows=0.3) (actual time=0.025..0.0878 rows=5 loops=1)
                -> Covering index lookup on ChannelMembers using idx_channelmembers_user_id_channel_id_last_viewed_at (UserId='')  (cost=0.916 rows=6) (actual time=0.0146..0.023 rows=6 loops=1)
                -> Filter: ((channels.DeleteAt = 0) and (channels.TeamId = '') and (channels.`Type` in ('O','P')))  (cost=0.251 rows=0.05) (actual time=0.00999..0.0102 rows=0.833 loops=6)
                    -> Single-row index lookup on Channels using PRIMARY (Id=channelmembers.ChannelId)  (cost=0.251 rows=1) (actual time=0.00778..0.00785 rows=1 loops=6)
            -> Nested loop inner join  (cost=2.85 rows=4.81) (actual time=102..102 rows=0 loops=5)
                -> Covering index lookup on SidebarChannels using PRIMARY (ChannelId=channelmembers.ChannelId)  (cost=2.01 rows=4.81) (actual time=0.0125..13.8 rows=24134 loops=5)
                -> Filter: ((sidebarcategories.TeamId = '') and (sidebarcategories.UserId = ''))  (cost=1.54 rows=1) (actual time=0.00359..0.00359 rows=0 loops=120671)
                    -> Single-row index lookup on SidebarCategories using PRIMARY (Id=sidebarchannels.CategoryId)  (cost=1.54 rows=1) (actual time=0.00316..0.00319 rows=1 loops=120671)
```

NEW:
```
Here is the output

| -> Sort: channels.DisplayName  (actual time=0.12..0.12 rows=5 loops=1)
    -> Stream results  (cost=3.45 rows=4.01) (actual time=0.0797..0.11 rows=5 loops=1)
        -> Nested loop antijoin  (cost=3.45 rows=4.01) (actual time=0.0769..0.106 rows=5 loops=1)
            -> Nested loop inner join  (cost=3.02 rows=0.3) (actual time=0.0291..0.0555 rows=5 loops=1)
                -> Covering index lookup on ChannelMembers using idx_channelmembers_user_id_channel_id_last_viewed_at (UserId='')  (cost=0.916 rows=6) (actual time=0.0145..0.0162 rows=6 loops=1)
                -> Filter: ((channels.DeleteAt = 0) and (channels.TeamId = '') and (channels.`Type` in ('O','P')))  (cost=0.251 rows=0.05) (actual time=0.00611..0.00619 rows=0.833 loops=6)
                    -> Single-row index lookup on Channels using PRIMARY (Id=channelmembers.ChannelId)  (cost=0.251 rows=1) (actual time=0.0053..0.00534 rows=1 loops=6)
            -> Single-row index lookup on <subquery2> using <auto_distinct_key> (ChannelId=channelmembers.ChannelId)  (cost=7.01..7.01 rows=1) (actual time=0.00956..0.00956 rows=0 loops=5)
                -> Materialize with deduplication  (cost=7..7 rows=13.4) (actual time=0.0451..0.0451 rows=0 loops=1)
                    -> Filter: (sidebarchannels.ChannelId is not null)  (cost=5.66 rows=13.4) (actual time=0.0441..0.0441 rows=0 loops=1)
                        -> Nested loop inner join  (cost=5.66 rows=13.4) (actual time=0.0439..0.0439 rows=0 loops=1)
                            -> Covering index lookup on SidebarCategories using idx_sidebarcategories_userid_teamid (UserId='', TeamId='')  (cost=0.592 rows=3) (actual time=0.0105..0.0134 rows=3 loops=1)
                            -> Covering index lookup on SidebarChannels using idx_sidebarchannels_categoryid (CategoryId=sidebarcategories.Id)  (cost=1.39 rows=4.46) (actual time=0.00999..0.00999 rows=0 loops=3)
```

Performance improvement from 512ms to 0.12ms.

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

```release-note
NONE
```
2025-05-09 09:48:07 +05:30
Ben Schumacher
92011a6c75
[MM-29111] Fix errcheck issues in server/channels/app/upload.go (#30678)
Co-authored-by: Claude <noreply@anthropic.com>
2025-05-07 13:40:51 +02:00
Ben Schumacher
bfb15ab179
[MM-61074] Fix errcheck issues in oauth_test.go and web_test.go (#30707)
Co-authored-by: Claude <noreply@anthropic.com>
2025-05-07 12:41:10 +02:00
Ben Schumacher
dc2827a63e
[MM-28923] Fix errcheck issues in server/channels/app/file.go (#30878)
Co-authored-by: Claude <noreply@anthropic.com>
2025-05-07 10:04:17 +02:00
Ben Schumacher
e10a1309c1
[MM-61774] Fix errcheck issues in server/channels/app/platform/status.go (#30876)
Co-authored-by: Claude <noreply@anthropic.com>
2025-05-07 09:04:22 +02:00
Harshil Sharma
a5e68639c2
Channel banner permissions (#30917)
* Fixed save state panel for channel banner

* Defined default background color

* Updated test

* WIP

* wip

* removed unused param

* Updated tests

* CI

* Fixed mmctl test

* Fixed TestDoAdvancedPermissionsMigration test

* Test update

* lint fix

* lint fix

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-06 14:03:35 +05:30
Harrison Healey
0c38d893e3
Fix errcheck issue on master (#30938) 2025-05-05 16:36:25 +00:00
Ivy Gesare
1bca62dc83
[MM-61505] Fix errcheck issues in server/channels/app/team_test.go (#29146)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-05-05 12:43:16 +02:00
kasyap dharanikota
ddb4c4360c
fix errcheck in server/channels/app/platform/session.go (#30595)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-05-05 12:18:47 +02:00
Harshil Sharma
a76c063d85
Renamed premium SKU to Enterprise Advanced (#30882) 2025-05-02 11:34:46 +05:30
Jesse Hallam
e1f47e22e7
MM-62158: group store no SELECT * (Part 1) (#30276)
* improved test coverage

* initial pass on removing SELECT * from group store
2025-05-01 09:39:05 -03:00
Miguel de la Cruz
2decc2ccdb
Prevent synced CPA values to be updated from the API (#30687)
* Prevents the API from updating synced CPA values

The patch functions for CPA values now accept a parameter that checks
if they should allow for synced values to be updated, and prevent
those updates if necessary

* Fix linter

* Fix parameter after merge

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-30 18:43:05 +02:00
Ben Schumacher
df3560ed9c
[MM-61086] Fix errcheck linter issue in batch_worker_test.go (#30644) 2025-04-29 11:08:38 +02:00
Ben Schumacher
f1ddeec2f6
[MM-61778] Fix errcheck issues in web_hub_test.go (#30676)
Co-authored-by: Claude <noreply@anthropic.com>
2025-04-29 10:23:53 +02:00
Ben Schumacher
2f5b70bfa2
[MM-29108] Fix errcheck issues in server/channels/app/team.go (#30683)
Co-authored-by: Claude <noreply@anthropic.com>
2025-04-29 09:03:06 +02:00
Ben Schumacher
d0c4780eb1
[MM-28761] Fix errcheck linter issues in hosted_purchase_screening worker (#30624) 2025-04-29 08:57:52 +02:00
Ben Schumacher
5ee308bd83
[MM-61467] Fix errcheck linter issues in post_test.go (#30686) 2025-04-29 08:50:47 +02:00
Agniva De Sarker
efde5e2717
[AI assisted] MM-62755: Refactor scanning to map to a util (#30780)
With some neat generics, I was able to refactor
the scanning to a util function. I used it to
refactor 3 places and also removed an unnecessary method.

Claude was quite good here.

https://mattermost.atlassian.net/browse/MM-62755
```release-note
NONE
```
2025-04-28 19:21:12 +05:30
Ben Schumacher
cd5523f5fb
MM-29092 Fix error handling in auto_environment.go (#30610)
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2025-04-28 15:05:31 +02:00
Ben Schumacher
eea39a5f23
[MM-61087] Fix errcheck linter issues in channels/jobs/helper_test.go (#30643)
Co-authored-by: Claude <noreply@anthropic.com>
2025-04-28 15:02:10 +02:00
Ben Schumacher
6a228877b7
[MM-28762] Fix errcheck issues in jobs.go (#30708)
Co-authored-by: Claude <noreply@anthropic.com>
2025-04-28 14:57:40 +02:00
Ben Schumacher
6fc60c8e5f
[MM-61105] Fix errcheck linter errors in config_test.go (#30689) 2025-04-28 14:53:45 +02:00
Agniva De Sarker
29f7c895b8
MM-63878: Fix INSERT IGNORE in saveChannelT (#30850)
INSERT IGNORE will ignore ALL errors in the INSERT statement.
This is not what was intended. The right way is to do a
redundant update on duplicate key.

It's not great, but that's how MySQL wants us to do it.

https://mattermost.atlassian.net/browse/MM-63878
```release-note
NONE
```
2025-04-24 21:29:09 +05:30
Agniva De Sarker
131cf039bb
MM-63756: Added index to sidebarchannels table (#30724)
The (s SqlChannelStore) getSidebarCategoriesT gets called quite frequently.
- Team switch
- WS reconnect
- Category created
- Category updated
- Category deleted

Of these 1 and 2 are probably the most commonly called sources. Based on that,
the sidebarChannels table is not that well-optimized. Even though
the query time might be reasonable, without an index, it has to churn a lot of
DB CPU for a sequential scan.

We add a new index to optimize this.

CREATE INDEX idx_sidebarchannels_categoryid ON sidebarchannels(categoryid);

```
Before:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=40854.18..40854.19 rows=4 width=193) (actual time=251.635..251.646 rows=204 loops=1)
   Sort Key: sidebarcategories.sortorder, sidebarchannels.sortorder
   Sort Method: quicksort  Memory: 65kB
   Buffers: shared hit=1203 read=23668
   ->  Nested Loop  (cost=8.87..40854.14 rows=4 width=193) (actual time=251.345..251.455 rows=204 loops=1)
         Buffers: shared hit=1203 read=23668
         ->  Nested Loop  (cost=0.41..9.47 rows=1 width=54) (actual time=0.068..0.074 rows=1 loops=1)
               Buffers: shared hit=5
               ->  Seq Scan on teams  (cost=0.00..1.03 rows=1 width=27) (actual time=0.024..0.026 rows=1 loops=1)
                     Filter: (((id)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text) AND (deleteat = 0))
                     Rows Removed by Filter: 1
                     Buffers: shared hit=1
               ->  Index Scan using teammembers_pkey on teammembers  (cost=0.41..8.43 rows=1 width=27) (actual time=0.039..0.043 rows=1 loops=1)
                     Index Cond: (((teamid)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text) AND ((userid)::text = 'tc3p1yqw67d8idcp3g98awexqe'::text))
                     Filter: (deleteat = 0)
                     Buffers: shared hit=4
         ->  Hash Right Join  (cost=8.45..40844.62 rows=4 width=193) (actual time=251.274..251.361 rows=204 loops=1)
               Hash Cond: ((sidebarchannels.categoryid)::text = (sidebarcategories.id)::text)
               Buffers: shared hit=1198 read=23668
               ->  Seq Scan on sidebarchannels  (cost=0.00..37514.77 rows=1265277 width=100) (actual time=0.043..99.345 rows=1265444 loops=1)
                     Buffers: shared hit=1194 read=23668
               ->  Hash  (cost=8.44..8.44 rows=1 width=158) (actual time=0.047..0.047 rows=6 loops=1)
                     Buckets: 1024  Batches: 1  Memory Usage: 10kB
                     Buffers: shared hit=4
                     ->  Index Scan using idx_sidebarcategories_userid_teamid on sidebarcategories  (cost=0.42..8.44 rows=1 width=158) (actual time=0.029..0.037 rows=6 loops=1)
                           Index Cond: (((userid)::text = 'tc3p1yqw67d8idcp3g98awexqe'::text) AND ((teamid)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text))
                           Buffers: shared hit=4
 Planning:
   Buffers: shared hit=9
 Planning Time: 1.215 ms
 Execution Time: 251.755 ms
(31 rows)

After:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=1544.53..1544.54 rows=4 width=192) (actual time=0.834..0.859 rows=204 loops=1)
   Sort Key: sidebarcategories.sortorder, sidebarchannels.sortorder
   Sort Method: quicksort  Memory: 65kB
   Buffers: shared hit=58
   ->  Nested Loop Left Join  (cost=8.53..1544.49 rows=4 width=192) (actual time=0.066..0.252 rows=204 loops=1)
         Buffers: shared hit=58
         ->  Nested Loop  (cost=0.83..17.93 rows=1 width=157) (actual time=0.042..0.098 rows=6 loops=1)
               Buffers: shared hit=34
               ->  Nested Loop  (cost=0.42..9.48 rows=1 width=157) (actual time=0.030..0.049 rows=6 loops=1)
                     Buffers: shared hit=10
                     ->  Index Scan using idx_sidebarcategories_userid_teamid on sidebarcategories  (cost=0.42..8.44 rows=1 width=157) (actual time=0.018..0.022 rows=6 loops=1)
                           Index Cond: (((userid)::text = 'tc3p1yqw67d8idcp3g98awexqe'::text) AND ((teamid)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text))
                           Buffers: shared hit=4
                     ->  Seq Scan on teams  (cost=0.00..1.03 rows=1 width=27) (actual time=0.002..0.003 rows=1 loops=6)
                           Filter: (((id)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text) AND (deleteat = 0))
                           Rows Removed by Filter: 1
                           Buffers: shared hit=6
               ->  Index Scan using teammembers_pkey on teammembers  (cost=0.41..8.43 rows=1 width=27) (actual time=0.007..0.007 rows=1 loops=6)
                     Index Cond: (((teamid)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text) AND ((userid)::text = 'tc3p1yqw67d8idcp3g98awexqe'::text))
                     Filter: (deleteat = 0)
                     Buffers: shared hit=24
         ->  Bitmap Heap Scan on sidebarchannels  (cost=7.69..1522.35 rows=421 width=100) (actual time=0.012..0.017 rows=34 loops=6)
               Recheck Cond: ((categoryid)::text = (sidebarcategories.id)::text)
               Heap Blocks: exact=6
               Buffers: shared hit=24
               ->  Bitmap Index Scan on idx_sidebarchannels_categoryid  (cost=0.00..7.58 rows=421 width=0) (actual time=0.010..0.010 rows=34 loops=6)
                     Index Cond: ((categoryid)::text = (sidebarcategories.id)::text)
                     Buffers: shared hit=18
 Planning:
   Buffers: shared hit=18
 Planning Time: 0.543 ms
 Execution Time: 0.968 ms
(32 rows)
```

I have also looked at potentially re-ordering the JOINs to make
sidebarchannels and sidebarcategories JOIN earlier, but that didn't give
a major benefit.

Also looked at adding a compound index with (categoryid, sortorder) to improve
sorting performance, but that didn't give a major benefit from what the single
column index already gives.

The `completePopulatingCategoryChannelsT` query also partially benefits
from this. But the Postgres optimizer sometimes selects the index on categoryId
and sometimes on ChannelId, both giving equivalent performance. So there's no major
improvement there, but at the same time, no regression as well.

```
Original:
[bigdb] # EXPLAIN (ANALYZE, BUFFERS) SELECT Id FROM ChannelMembers LEFT JOIN Channels ON Channels.Id=ChannelMembers.ChannelId WHERE (ChannelMembers.UserId = 'tc3p1yqw67d8idcp3g98awexqe' AND Channels.Type IN ('D'
                                                                                                                                                                                                                ,'G') AND Channels.DeleteAt = 0 AND NOT EXISTS ( SELECT 1 FROM SidebarChannels JOIN SidebarCategories on SidebarChannels.CategoryId=SidebarCategories.Id WHERE (SidebarChannels.ChannelId = ChannelMembers.ChannelI
                                                                                                                                                                                                                                                                                                                                                                                d AND SidebarCategories.UserId = 'tc3p1yqw67d8idcp3g98awexqe' AND SidebarCategories.TeamId = '3ee5y5ok6jgxicrmqstdnghmfr') )) ORDER BY DisplayName ASC;
                                                                                            QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=5864.68..5865.84 rows=463 width=40) (actual time=9.008..9.022 rows=39 loops=1)
   Sort Key: channels.displayname
   Sort Method: quicksort  Memory: 27kB
   Buffers: shared hit=2112
   ->  Nested Loop Anti Join  (cost=1.96..5844.18 rows=463 width=40) (actual time=0.188..8.932 rows=39 loops=1)
         Buffers: shared hit=2112
         ->  Nested Loop  (cost=0.99..3476.66 rows=463 width=67) (actual time=0.159..7.952 rows=39 loops=1)
               Buffers: shared hit=1956
               ->  Index Only Scan using idx_channelmembers_user_id_channel_id_last_viewed_at on channelmembers  (cost=0.56..40.78 rows=470 width=27) (actual time=0.036..0.467 rows=437 loops=1)
                     Index Cond: (userid = 'tc3p1yqw67d8idcp3g98awexqe'::text)
                     Heap Fetches: 45
                     Buffers: shared hit=208
               ->  Memoize  (cost=0.43..7.69 rows=1 width=40) (actual time=0.016..0.016 rows=0 loops=437)
                     Cache Key: channelmembers.channelid
                     Cache Mode: logical
                     Hits: 0  Misses: 437  Evictions: 0  Overflows: 0  Memory Usage: 42kB
                     Buffers: shared hit=1748
                     ->  Index Scan using channels_pkey on channels  (cost=0.42..7.68 rows=1 width=40) (actual time=0.015..0.015 rows=0 loops=437)
                           Index Cond: ((id)::text = (channelmembers.channelid)::text)
                           Filter: ((type = ANY ('{D,G}'::channel_type[])) AND (deleteat = 0))
                           Rows Removed by Filter: 1
                           Buffers: shared hit=1748
         ->  Nested Loop  (cost=0.97..5.10 rows=1 width=27) (actual time=0.023..0.023 rows=0 loops=39)
               Buffers: shared hit=156
               ->  Index Only Scan using sidebarchannels_pkey on sidebarchannels  (cost=0.55..4.56 rows=1 width=92) (actual time=0.022..0.022 rows=0 loops=39)
                     Index Cond: (channelid = (channelmembers.channelid)::text)
                     Heap Fetches: 0
                     Buffers: shared hit=156
               ->  Index Scan using sidebarcategories_pkey on sidebarcategories  (cost=0.42..0.48 rows=1 width=65) (never executed)
                     Index Cond: ((id)::text = (sidebarchannels.categoryid)::text)
                     Filter: (((userid)::text = 'tc3p1yqw67d8idcp3g98awexqe'::text) AND ((teamid)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text))
 Planning:
   Buffers: shared hit=48 dirtied=1
 Planning Time: 2.222 ms
 Execution Time: 9.142 ms
(35 rows)

New:
[bigdb] # EXPLAIN (ANALYZE, BUFFERS) SELECT Id FROM ChannelMembers LEFT JOIN Channels ON Channels.Id=ChannelMembers.ChannelId WHERE (ChannelMembers.UserId = 'tc3p1yqw67d8idcp3g98awexqe' AND Channels.Type IN ('D'
                                                                                                                                                                                                                ,'G') AND Channels.DeleteAt = 0 AND NOT EXISTS ( SELECT 1 FROM SidebarChannels JOIN SidebarCategories on SidebarChannels.CategoryId=SidebarCategories.Id WHERE (SidebarChannels.ChannelId = ChannelMembers.ChannelId AND SidebarCategories.UserId = 'tc3p1yqw67d8idcp3g98awexqe' AND SidebarCategories.TeamId = '3ee5y5ok6jgxicrmqstdnghmfr') )) ORDER BY DisplayName ASC;
                                                                                            QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=5059.95..5061.11 rows=463 width=40) (actual time=12.072..12.086 rows=39 loops=1)
   Sort Key: channels.displayname
   Sort Method: quicksort  Memory: 27kB
   Buffers: shared hit=1984
   ->  Nested Loop Anti Join  (cost=9.10..5039.45 rows=463 width=40) (actual time=0.751..12.009 rows=39 loops=1)
         Join Filter: ((sidebarchannels.channelid)::text = (channelmembers.channelid)::text)
         Rows Removed by Join Filter: 7839
         Buffers: shared hit=1984
         ->  Nested Loop  (cost=0.99..3476.66 rows=463 width=67) (actual time=0.161..7.579 rows=39 loops=1)
               Buffers: shared hit=1956
               ->  Index Only Scan using idx_channelmembers_user_id_channel_id_last_viewed_at on channelmembers  (cost=0.56..40.78 rows=470 width=27) (actual time=0.036..0.449 rows=437 loops=1)
                     Index Cond: (userid = 'tc3p1yqw67d8idcp3g98awexqe'::text)
                     Heap Fetches: 45
                     Buffers: shared hit=208
               ->  Memoize  (cost=0.43..7.69 rows=1 width=40) (actual time=0.016..0.016 rows=0 loops=437)
                     Cache Key: channelmembers.channelid
                     Cache Mode: logical
                     Hits: 0  Misses: 437  Evictions: 0  Overflows: 0  Memory Usage: 42kB
                     Buffers: shared hit=1748
                     ->  Index Scan using channels_pkey on channels  (cost=0.42..7.68 rows=1 width=40) (actual time=0.014..0.014 rows=0 loops=437)
                           Index Cond: ((id)::text = (channelmembers.channelid)::text)
                           Filter: ((type = ANY ('{D,G}'::channel_type[])) AND (deleteat = 0))
                           Rows Removed by Filter: 1
                           Buffers: shared hit=1748
         ->  Materialize  (cost=8.11..1535.03 rows=4 width=27) (actual time=0.003..0.046 rows=201 loops=39)
               Buffers: shared hit=28
               ->  Nested Loop  (cost=8.11..1535.01 rows=4 width=27) (actual time=0.099..0.383 rows=201 loops=1)
                     Buffers: shared hit=28
                     ->  Index Scan using idx_sidebarcategories_userid_teamid on sidebarcategories  (cost=0.42..8.44 rows=1 width=65) (actual time=0.047..0.057 rows=6 loops=1)
                           Index Cond: (((userid)::text = 'tc3p1yqw67d8idcp3g98awexqe'::text) AND ((teamid)::text = '3ee5y5ok6jgxicrmqstdnghmfr'::text))
                           Buffers: shared hit=4
                     ->  Bitmap Heap Scan on sidebarchannels  (cost=7.69..1522.35 rows=421 width=92) (actual time=0.028..0.040 rows=34 loops=6)
                           Recheck Cond: ((categoryid)::text = (sidebarcategories.id)::text)
                           Heap Blocks: exact=6
                           Buffers: shared hit=24
                           ->  Bitmap Index Scan on idx_sidebarchannels_categoryid  (cost=0.00..7.58 rows=421 width=0) (actual time=0.023..0.023 rows=34 loops=6)
                                 Index Cond: ((categoryid)::text = (sidebarcategories.id)::text)
                                 Buffers: shared hit=18
 Planning:
   Buffers: shared hit=51
 Planning Time: 2.240 ms
 Execution Time: 12.210 ms
(42 rows)
```

Analysis on MySQL for completion:
```
Before:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Sort: SidebarCategories.SortOrder, SidebarChannels.SortOrder  (actual time=277.675..277.675 rows=4 loops=1)
    -> Stream results  (cost=138558.36 rows=1287808) (actual time=242.506..277.650 rows=4 loops=1)
        -> Left hash join (<hash>(SidebarChannels.CategoryId)=<hash>(SidebarCategories.Id)), extra conditions: (SidebarChannels.CategoryId = SidebarCategories.Id)  (cost=138558.36 rows=1287808) (actual time=242.498..277.626 rows=4 loops=1)
            -> Index lookup on SidebarCategories using idx_sidebarcategories_userid_teamid (UserId='qdggj9pyobgkjpj8htwzizks1r', TeamId='xmh7bupzajnudqf3h4mm76qapy')  (cost=1.40 rows=4) (actual time=0.092..0.094 rows=4 loops=1)
            -> Hash
                -> Table scan on SidebarChannels  (cost=8394.55 rows=321952) (actual time=0.123..106.334 rows=300002 loops=1)
 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

After:
----------------------------------------------------------------+
| -> Sort: SidebarCategories.SortOrder, SidebarChannels.SortOrder  (actual time=0.739..0.742 rows=4 loops=1)
    -> Stream results  (cost=6.80 rows=7) (actual time=0.468..0.703 rows=4 loops=1)
        -> Nested loop left join  (cost=6.80 rows=7) (actual time=0.456..0.673 rows=4 loops=1)
            -> Index lookup on SidebarCategories using idx_sidebarcategories_userid_teamid (UserId='qdggj9pyobgkjpj8htwzizks1r', TeamId='xmh7bupzajnudqf3h4mm76qapy')  (cost=4.38 rows=4) (actual time=0.302..0.313 rows=4 loops=1)
            -> Index lookup on SidebarChannels using idx_sidebarchannels_categoryid (CategoryId=SidebarCategories.Id)  (cost=0.48 rows=2) (actual time=0.085..0.087 rows=0 loops=4)
 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
```

Timing wise, it takes around 2s to add the index on a table with 1.2M rows
for Postgres. And it takes around 5s on MySQL on a table with 300K rows.
It looks like it takes longer on MySQL, but since both migrations are
non-locking, it should be fine.

https://mattermost.atlassian.net/browse/MM-63756
```release-note
NONE
```
2025-04-24 12:11:28 +05:30
Jesse Hallam
011f179831
avoid SELECT * in preference store (#30835) 2025-04-23 15:06:04 -04:00
Pablo Vélez
6ae0efd285
MM61173 - settings modal base creation (#30338)
* MM-61173 - channel settings modal: base modal, initial commit, file creation and base component

* new enhancements to the base modal creation

* revert changes on textbox_links and edit channel header

* fix types and add back unintentioned deleted value

* add the preview textbox component

* extract logic for info tab into its own component

* add the purpose input to the window

* move other component logic to its own component and code clean up

* ability to update channel type

* more advances on the archive channel tab

* fix unit test in textbox

* fix translations

* do not show the archive modal in default channel

* fix issue with url editor not being resetted on undo action

* adjust text and styling for the header and purpose inputs

* remove textboxlinks and use button eye icon

* adjust test and preview button style

* add unit test to channel patch

* move logic from parent modal to info tab component

* fix border issues and focus back to preview textareas

* prevent saving changes when pressing enter when selecting an icon

* enhance input component to cover limits validations and enhances tests

* set default error message for save changes panel

* add props to provide custom value to the buttons

* remove channel input errors on reset button click

* create new component settings textbox

* rename component to advanced textbox and add unit tests

* styling of the info tab and add error state to advanced textbox

* add logic to prevent tab switch with unsaved changes

* adjust url error logic and code clean up

* code clean up and enhance comments

* add char min length to advanced textbox logic

* add the channel settings modal to the new menu

* add new test files and fix reset error

* remove unused error variables

* adjust translations and remove unncesary import

* enhance permissions for archive channels and manage channel settings

* Adjust permission tree so channel admins can convert from private to public

* enhance the test suit around channel conversion type

* fix some e2e tests and solve channel input name issue

* fix unit test by interacting first with the input element

* adjust e2e tests to channel settings modal changes

* remove commented tests and implement pr feedback

* adjust more pr feedback to the code

* more pr feedback enhancements

* further enhancements to tab navigation, and adjust more e2e tests

* remove unused components and fix e2e tests

* revert unnecessary permissions changes

* Add name label to textboxes

* adjust e2e and unit tests

* revert min lenght change value and adjust tests and snapshots

* Channel banner settings (#30721)

* Added channel banner setting header

* Updated section styling

* handled animation

* handled min and max lengths

* cleanup

* color change fix

* general improvements

* Fixed API test

* removed unused param className

* added e2e tests

* test: add channel settings configuration tab test file

* Based on the context, here's a concise commit message for this change:

feat: Add comprehensive tests for ChannelSettingsConfigurationTab

* added some more tests

* CI

* reverted package-lock.json changes in Playwright

* remove extra border from advaced textbox

* adjust styling for name label in advance texbox and restart preview state on modal close

* sync package.lock in playwright

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
Co-authored-by: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com>
2025-04-23 12:49:54 +02:00
Jesse Hallam
f6aeca7e50
avoid SELECT * in jobs store (#30832) 2025-04-23 12:11:09 +05:30
Jesse Hallam
3c9b2511bc
avoid SELECT * in audit store (#30829) 2025-04-23 08:37:06 +02:00
Jesse Hallam
94bc32b50c
avoid SELECT * in cluster discovery store (#30830) 2025-04-23 05:08:43 +08:00
Jesse Hallam
b095ba22b8
avoid SELECT * in notify admin store (#30834) 2025-04-22 17:27:33 -03:00
Jesse Hallam
018c909e2f
avoid SELECT * in command stores (#30831)
* avoid SELECT * in command stores

* Define column names once and reuse as columns list in selects and inserts

* Define column names once and reuse with ExecBuilder
2025-04-22 19:37:10 +00:00
Jesse Hallam
981d1d869a
avoid SELECT * in channel member history store (#30828) 2025-04-22 15:33:32 -04:00
Jesse Hallam
eb8aaba1bf
avoid SELECT * in link metadata store (#30833)
* avoid SELECT * in link metadata store

* Address PR comment: define column names once and reuse
2025-04-22 19:29:09 +00:00
Jesse Hallam
701ddc896a
MM-63791: guest permissions to teams (#30789)
* improve th.CreateGuestAndClient

* test coverage for guest user access to teams

* restrict guest access to public teams unless a member
2025-04-22 10:12:22 -03:00
Agniva De Sarker
d8dbb6cc22
MM-56548: [AI assisted]Add support for incremental thread loading using UpdateAt timestamp (#30486)
Every time we load the RHS, we used to load the FULL thread always. Although
the actual ThreadViewer React component is virtualized, and the server side
API call is paginated, we still went through all the pages, to get the full
thread and passed it on to the ThreadViewer. This would be for first loads,
and subsequent loads of the same thread.

This was a bug originally, but then it was a necessity after we applied websocket event scope because
now we won't get emoji reactions of a thread if the user is not on the thread.

To fix that, we enhance the thread loading functionality by adding support for fetching
thread updates based on the UpdateAt timestamp. Now, for subsequent loads,
we only get the changed posts in a thread. The implementation:

- Adds new API parameters: fromUpdateAt and updatesOnly to the GetPostThread endpoint
- Updates database queries to support sorting and filtering by UpdateAt
- Implements thread state management to track the last update timestamp
- Adds client-side support to use incremental loading for improved performance
- Ensures proper validation for parameter combinations and error handling

This change enables more efficient thread loading, particularly for long threads
with frequent updates, by only fetching posts that have been updated since the
last view.

Caveats: For delta updates, the SQL query won't use the best index possible
because we have an index for (CreateAt, Id), but no index for (UpdateAt, Id).
However, from my tests, it is not as bad as it looks:

```
[loadtest] # EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM Posts WHERE Posts.DeleteAt = 0 AND Posts.RootId = 'qbr5gctu9iyg8c36hpcq6f3w8e' AND Posts.UpdateAt > 1623445795824 ORDER BY UpdateAt ASC, Id ASC LIMIT 61;
                                                                   QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=8.31..8.31 rows=1 width=216) (actual time=0.047..0.049 rows=0 loops=1)
   Buffers: shared hit=2
   ->  Sort  (cost=8.31..8.31 rows=1 width=216) (actual time=0.044..0.045 rows=0 loops=1)
         Sort Key: updateat, id
         Sort Method: quicksort  Memory: 25kB
         Buffers: shared hit=2
         ->  Index Scan using idx_posts_root_id_delete_at on posts  (cost=0.28..8.30 rows=1 width=216) (actual time=0.031..0.032 rows=0 loops=1)
               Index Cond: (((rootid)::text = 'qbr5gctu9iyg8c36hpcq6f3w8e'::text) AND (deleteat = 0))
               Filter: (updateat > '1623445795824'::bigint)
               Buffers: shared hit=2
 Planning:
   Buffers: shared hit=3
 Planning Time: 0.508 ms
 Execution Time: 0.106 ms
(14 rows)
```

We still get an index scan with index cond. Although there's a filter element, but atleast we get the whole thread with the index.
My thinking is that while the whole thread might be large, but after that, updates on a thread should be incremental.
Therefore, we should be okay without adding yet another index on the posts table.

This is just the first step in what could be potentially improved further.

1. We shouldn't even be loading the full thread always. But rather let the virtualized viewer
load more posts on demand.
2. If a post has been just reacted to, then we need not send the whole post down, but just the
reaction. This further saves bandwidth.

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

TBD: Add load-test coverage to update the thread loading code

```release-note
NONE
```
---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-22 10:43:13 +05:30
Jesse Hallam
b59f10cbbd
MM-62158: Group Store, explicit aliases (#30741) 2025-04-17 17:37:28 -03:00
Jesse Hallam
4a93939359
MM-63728: Add license load metric endpoint and UI indicator (#30700)
* Add license load metric endpoint and UI indicator

Adds an API endpoint to calculate and return license usage as a load metric, and displays this metric in the About dialog. The metric is calculated as (MAU/licensed users)*100.

Additionally:
- Renamed function to be consistent with API endpoint name
- Added proper i18n strings for error messages and UI elements

* Fix TypeScript null check in about_build_modal.tsx

* MM-63728: Update OpenAPI documentation for license load metric

Update the OpenAPI documentation and code comments to correctly describe the license load metric calculation as using a multiplier of 1000 instead of percentage.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* MM-63728: Use float for license load metric calculation

Modify the license load metric calculation to use floats throughout the computation process while still returning an integer result. This maintains the existing API but improves the precision of the calculation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* improve tests manually

* Update server/channels/api4/license_test.go

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>

* Update server/channels/api4/license_test.go

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
2025-04-17 17:29:46 -03:00
Miguel de la Cruz
3df7bfca88
Improves validation and sanitization for CPA fields and values (#30694)
This change automatically removes options and sync attributes when
sanitizing fields that don't support them. As per values, it returns
an error when the value for a text type field is longer than the 64
characters limit we're currently applying.

The PR fixes a bug on the create CPA field endpoint that was causing
the attrs of the CPAField not to be decoded correctly.

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-04-16 16:04:30 +02:00
Nick Misasi
495a49b896
Feature/audit certificate upload (#30223)
* feat: Add certificate upload option for audit logging settings

* Commit current changes

* Additions

* MM-62944 Fix fileupload settings not being clickable

* Support for uploading a cert for experimental audit logging cert. Pre cloud implementation in the backend

* Forgot to add new hook

* Add support for setting custom audit log certifcates in Cloud

* Permissions

* I18n

* Change order

* Linter fixes

* Linter fixes, add openapi spec

* additions for openapi

* More openapi fixes because it won't run locally

* Undo, cursor went rogue

* newline fix

* Align types properly

* Fix i18n

* Fix i18n AGAIN

* Fix error

* Update api/v4/source/audit_logging.yaml

---------

Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-16 09:34:18 -04:00
Ben Schumacher
efd17a37ea
[MM-28948] Fix errcheck linter issues in import_functions.go (#30615)
Co-authored-by: Claude <noreply@anthropic.com>
2025-04-15 09:53:38 +02:00
Ben Schumacher
b7f89984db
[MM-61076] Fix errcheck issues in server/channels/web/saml.go (#30612)
Co-authored-by: Claude <noreply@anthropic.com>
2025-04-15 09:52:28 +02:00
Ben Schumacher
b8ad438c0a
[MM-61515] Fix errcheck linter issues in webhook_test.go (#30684) 2025-04-15 09:50:22 +02:00
Agniva De Sarker
848bac2bae
MM-53739: replace store.NewErrNotFound with errors.Wrap in category queries (#30712)
It was a mistake to return ANY error as NewErrNotFound. Because this
can be a DB timeout, or any other network error.

Returning NewErrNotFound would categorize it as 404, eventually printing
the error in the DEBUG level. Changing it to normal error fixes this.

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

```release-note
NONE
```
2025-04-14 21:11:59 +05:30
Jesse Hallam
b84d913243
flaky test: Avoid team names that start with "A". (#30651)
This avoids a non-zero chance we append "pi" from the `model.NewId` and
end up with an invalid prefix "Api".

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-14 12:47:38 +00:00
Jesse Hallam
949a19efc1
MM-62156: Avoid SELECT * in retention_policy_store.go (#30458)
* MM-62156: Avoid SELECT * in retention_policy_store.go

- Modified subQueryIN function to use specific column name instead of SELECT *
- Improved code comments to explain the change
- Maintained same functionality while avoiding SELECT *

Fixes: https://mattermost.atlassian.net/browse/MM-62156

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* simplify subQueryIN comments

* inline part of subQueryIN for greater clarity

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-14 09:21:13 -03:00
Arya Khochare
0f860f0512
Fixed errcheck issues in server/channels/app/integration_action.go (#29040)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-04-14 13:56:05 +02:00
catalintomai
c23f44fe8e
MM-63316: Guest access to channel (#30467) 2025-04-14 13:07:50 +02:00
catalintomai
04676582cd
MM-63342:Bot accounts OAuth gating (#30466) 2025-04-14 11:51:46 +02:00
kasyap dharanikota
ae046fb34e
fix: handle error from InvalidateAllCaches in slack.go (#30606)
* fix: hanlde error from InvalidateAllCaches in slack.go

* change signature of InvalidateAllCaches to *model.AppError

* return  err from InvalidateAllCaches everywhere

* Formatting

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-04-14 10:24:21 +02:00
Ben Schumacher
4d0109feeb
[MM-61082] Fix errcheck issues in license_test.go (#30617)
* [MM-28754] Fix errcheck issues in license_test.go

- Properly handle error returned from os.WriteFile
- Remove license_test.go from errcheck exceptions list in .golangci.yml

Fixes https://github.com/mattermost/mattermost/issues/28754

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove empty line

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-04-14 09:28:28 +02:00
Pablo Vélez
02c7678438
MM-63590 - validate user has proper permission when updating team privacy (#30650)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-12 17:29:50 +02:00
Ben Schumacher
b8bf2e235d
[MM-61463] Fix errcheck issues in post_helpers_test.go (#30609)
* [MM-61463] Fix errcheck issues in post_helpers_test.go

- Added proper error handling for System.Save calls
- Removed post_helpers_test.go from errcheck ignore list in .golangci.yml

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add back         channels/app/plugin_test.go|

* Fix server/.golangci.yml

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-04-11 13:51:08 +02:00
Ben Schumacher
545de88486
[MM-61079] Fix error checking in webhook.go (#30611)
* MM-28751 Fix error checking in webhook.go

- Implement proper error checking for r.ParseForm()
- Implement proper error checking for r.ParseMultipartForm()
- Implement proper error checking for w.Write()
- Remove webhook.go exception from .golangci.yml

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix translation

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-04-11 12:17:43 +02:00
Arya Khochare
2e2782e4bf
Fixed errcheck issues in server/channels/app/file_bench_test.go (#29003)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-11 12:12:59 +02:00
Ben Schumacher
748f8227e3
Fix errcheck error in plugin_test.go by properly handling error from th.App.ch.RemovePlugin (#30608) 2025-04-11 10:42:16 +02:00
David Krauser
f53625d59f
[MM-63693] Don't log PING websocket events (#30669) 2025-04-10 16:24:23 -04:00
Jesse Hallam
42274b9eee
MM-63200: unrestricted local admin (#30295)
* use SessionHasPermissionToCheckRestrictedAdmin

* allow unrestricted config edits from localmode

* check model.PermissionManageSystem for getLatestVersion

* simplify/clarify RequestTrialLicense semantics

* rename for clarity

* whitespace from linter

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-10 22:22:03 +03:00
Miguel de la Cruz
ca9fd45408
Adds a mechanism to delete CPA values for a given user (#30330)
* Adds a mechanism to delete CPA values for a given user

This requires improving the Property Value service to enable delete
all values for a given target, so a new method was created that allows
to delete filtering by targetType and targetID (required) and
optionally for a specific groupID in case the caller wants to affect
all values for a target (useful in case you remove a post for example
and want to delete all values pointing to that post regardless of the
feature they belong to) or only those that belong to a specific
feature.

* Fix property value tests

* Fix after merge and update method name

* Fix linter

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-10 19:22:05 +02:00
Miguel de la Cruz
3ab0da1648
Adds direct participants to the channel invite (#30404)
* Adds direct participants to the channel invite

The channel invite now contains the sanitized users that are local to
the node that is sending the invite. In the event that the receiving
server doesn't have those users in its local database, it can create
them from the invite and correctly generate the DM or GM with them as
members.

* Use IsRemote instead of directly checking user attributes

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-10 19:19:59 +02:00
catalintomai
e7e80634d6
MM-43598: Bulk export not exporting non-thread DMs from deactivated users (#30427) 2025-04-10 15:12:33 +02:00
Miguel de la Cruz
0c8e30da4d
Move the sanitization and validation of CPA values to the model (#30653)
* Move the sanitization and validation of CPA values to the model

* Fix CI

* Use proper IDs instead of strings

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-10 11:31:40 +02:00
Ben Schumacher
02e5c56d22
MM-60797: Fix errcheck issues in support_packet_test.go (#30607)
Fixes https://github.com/mattermost/mattermost/issues/29102

- Fix error handling in fileutils.FindDir() call by properly checking the returned boolean value
- Add proper error handling for SetPhase2PermissionsMigrationStatus calls
- Remove channels/app/support_packet_test.go from the errcheck exception list in .golangci.yml

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-04-09 14:10:08 +02:00
Ben Schumacher
a6492b5b9f
MM-28765: Fix errcheck issues in server/channels/manualtesting/manual_testing.go (#30613)
1. Fixed hasher.Write() to check error return
2. Fixed VerifyEmail() to check error return
3. Fixed SaveMember() to check error return
4. Added typecheck exclusion for testAutoLink in .golangci.yml

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-04-09 11:41:56 +02:00
Ben Schumacher
354d7aeb72
Consistent error wrapping (#30600) 2025-04-09 11:38:36 +02:00
Surya Venkata Sainadh Pichika
62753a1481
[MM-63455] Fix Link previews with brackets when making the request (#30507)
* allow opening angle bracket before links

* cut off link before an angle bracket(both open & close)

* add more test cases for ParseURLAutolink func

* add more test cases for ParseWWWAutolink func

* add more test cases for TrimTrailingCharactersFromLink func

* add more test cases for GetFirstLinkAndImages func

* add test cases for isAllowedBeforeWWWLink func

* allow closing angle bracket and opening paranthesis before links

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-07 16:17:46 +05:30
Miguel de la Cruz
03d724b6a6
Adds the CPA property group endpoint (#30620)
* Adds the CPA property group endpoint

* Fix test calls

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-04-04 16:06:55 +00:00
Agniva De Sarker
09488558a0
MM-63298: [AI assisted] Elasticsearch add a global search prefix (#30417)
This PR adds functionality to search by a global search prefix.
This allows Mattermost to be used across multiple data centers
with multiple Elasticsearch instances synchronized using
cross-cluster replication.

While here, we also add tests cases to cover for some missing
search interface methods.

For now, no system console setting is exposed. Because IndexPrefix
is also not exposed. It can be added later if a need arises.

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

```release-note
A new config setting ElasticsearchSettings.GlobalSearchPrefix is added
which can be used to search across multiple indices having a common prefix.
This is useful in a scenario with multiple Elasticsearch instances, where
multiple instances are writing to different indices with different prefixes
using the ElasticsearchSettings.IndexPrefix setting.
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-04 11:42:12 +05:30
Claudio Costa
7250095f86
Fix potential nil dereference in app.isChannelArchivedAndHidden (#30628) 2025-04-03 15:31:09 -06:00
Harshil Sharma
a9f09cadc2
Premium SKU (#30396)
* Added premium SKU

* removed duplicate enterprise license check functions

* Added license check on API layer

* lint fix

* lint fix

* refactured signature:

* test: Add comprehensive tests for license tier check functions

* fixed test

* text update

* optimised license checks

* fixedf test

* Updated license valid function

* webapp license checks

* handling prekium SKU in webappp:

* added plugin api method and general refactoring

* Updated tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-03 13:07:54 +05:30
Julien Tant
65343f84a7
[MM-63480] Remove user cache early when deactivating user (#30571)
* remove user cache early when deactivating user

* add e2e test

* fix test style

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-02 12:31:07 -07:00
Jesse Hallam
d84be84f69
MM-62157: Avoid SELECT * in user_store.go (#30601)
* MM-62157: Avoid SELECT * in user_store.go

- Replace raw SQL query "SELECT * FROM Users" with query builder in Update method
- Replace raw SQL query "SELECT * from Users" with query builder in ClearAllCustomRoleAssignments
- Change Select("*") to Select("data.*") in GetUserReport method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62157: Avoid more instances of SELECT * in user_store.go

- Replace raw SQL query "Users.*, cm.ChannelId" with usersQuery in getUsersInGroupChannels
- Replace "Users.*" with getUsersColumns() in GetUserReport method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-04-02 11:06:09 -03:00
Ibrahim Serdar Acikgoz
10b1f4c5ac
[MM-63428] add access control policy store (#30597) 2025-04-02 13:39:28 +02:00
Ibrahim Serdar Acikgoz
3eb854c58d
[MM-63421] add openID Authorization API-compliant PDP interface (#30462) 2025-04-02 11:04:27 +02:00
Claudio Costa
f8e16780ef
[MM-63436] Replace Exif parser dependency (#30479)
* Replace Exif parser dependency

* Improve forward seeking logic

* Fix linting

* Stop decoding upon finding tag

* Use latest version of imagemeta dependency

* Don't skip TIFF reader tests

* Log improvements

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-04-01 13:57:43 -06:00
Ben Cooke
2454de5b4a
[MM-63504] When changing a channel to group synced, it doesn't always clear members (#30526)
* fix issue with channel and team membership after group constraints are enabled
2025-04-01 12:20:00 -04:00
Ben Cooke
ce9632cca3
MM-63311 (#30387)
* allow reference group changes
2025-03-31 15:49:55 -04:00
Miguel de la Cruz
1ca6f6d6fb
Adds a groupID filter to the property service methods (#30420)
* Adds a groupID filter to the property service methods

This allows the property service caller to directly ensure that a
given call is only going to affect a field or value that belongs to a
given group, instead of (for example) retrieving a property value
before deleting it by id to ensure that the value belongs to a
specific property group. The groupID filter is optional and has no
effect if called with the empty string value.

The changes also remove references to input sanitization on trimming
the whitespace for the CPA field names and validate at the API level
the input for the field patch endpoint.

* Fix linter

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-31 16:51:16 +00:00
Jesse Hallam
eb851684e9
MM-62162: Replace SELECT * in user_access_token_store.go (#30421)
* MM-62162: Replace SELECT * in user_access_token_store.go

- Replaced all SELECT * queries with explicit column selection
- Used query builder instead of raw SQL strings for all queries
- Added reusable userAccessTokensSelectQuery in the store constructor
- Added comprehensive test for pagination and IsActive flag

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* Fix code formatting in user_access_token_store test file

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62162: Update UserAccessToken Search method to use explicit column names

- Fixed "ambiguous column" errors by explicitly naming columns with table qualifiers
- Added test for the Search functionality

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62162: Update UserAccessToken Search method to use explicit column names

- Fixed "ambiguous column" errors by explicitly naming columns with table qualifiers
- Maintained exact semantics of original query's LIKE filters
- Refactored to use query builder instead of raw SQL

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62162: Update UserAccessToken Search method to use reusable query

- Modified userAccessTokensSelectQuery to use fully qualified column names
- Updated Search method to use the existing query builder
- Fixed "ambiguous column" errors by using full column qualifiers

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62162: Remove unnecessary comment in user_access_token_store.go

Removed redundant comment in Search method explaining the use of qualified column names, as the code is self-documenting.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62162: Use t.Cleanup() for token cleanup in userAccessTokenPagination test

* MM-62162: Handle error in Cleanup function

* linting

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-31 13:47:43 -03:00
Ben Schumacher
166a676fe5
Enforce use of any instead of interface{} (#30588) 2025-03-31 10:44:34 +02:00
Jesse Hallam
9aa4818c71
MM-62154: Avoid SELECT * in webhook_store.go (#30463)
* MM-62154: Avoid SELECT * in webhook_store.go

- Defined column list functions for both IncomingWebhooks and OutgoingWebhooks tables
- Converted all uses of SELECT * to use the column list functions
- Used the QueryBuilder pattern for SQL queries for better consistency and readability

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62154: Improve webhook store implementation using query builders

- Refactored webhook store to follow session_store.go pattern
- Added select query builders in the constructor
- Used pre-built queries throughout the store implementation for better maintainability and performance
- Removed redundant incomingWebhookColumns() and outgoingWebhookColumns() functions

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62154: Fix whitespace style issues in webhook_store.go

- Ran gofmt to remove trailing whitespace
- Ensures consistent code formatting

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62154: Remove unnecessary int(0) casting

- Simplified DeleteAt=0 condition by removing redundant int casting
- Maintains same behavior while making code cleaner

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-28 21:58:26 +00:00
Jesse Hallam
b1a8810bd8
MM-62160: Avoid SELECT * in user_terms_of_service.go and terms_of_service_store.go (#30423)
* MM-62160: Avoid SELECT * in user_terms_of_service.go

- Added userTermsOfServiceSelectQuery in the constructor
- Replaced raw SQL query with query builder pattern
- Used explicit column selection instead of SELECT *
- Made the implementation more resilient to schema changes

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62160: Also avoid SELECT * in terms_of_service_store.go

- Added termsOfServiceSelectQuery field to store struct
- Replaced SELECT * with explicit column selection
- Updated GetLatest and Get methods to use the query builder pattern
- Made the implementation more resilient to schema changes

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-28 15:44:52 -03:00
Harrison Healey
0079289224
MM-63577 Enable EnableLocalMode automatically during development (#30583) 2025-03-28 12:59:43 -04:00
Matthew Birtch
59cd90a36f
MM-61983 Update default bot image (#30539)
* updated default bot image

* Update bot_default_icon.png

* go:embed a copy of the new bot default icon

* updated bot avatar used for e2e tests

---------

Co-authored-by: Jesse Hallam <jesse@mattermost.com>
2025-03-28 10:49:09 -03:00
Jesse Hallam
63e85a3a2b
MM-62155: Avoid SELECT * in team_store.go (#30464)
* MM-62155: Avoid SELECT * in team_store.go

- Added explicit column lists for all SELECT queries
- Created teamSelectQuery for reused queries
- Replaced raw SQL queries with query builder pattern

* Refactor getTeamMembersWithSchemeSelectQuery to use teamMembersQuery builder

Instead of duplicating TeamMembers columns, use the existing builder to avoid redundancy.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove redundant comments from getTeamMembersWithSchemeSelectQuery

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-03-28 09:12:37 -03:00
Ben Schumacher
4156112f7c
Return error as last value in BulkImport functions (#30575) 2025-03-27 20:17:20 +01:00
Daniel Espino García
7999239ccf
Add system console settings for mobile security (#30456)
* Add config settings for additional security features on mobile

* Add system console settings for mobile security

* Update svg and link

* Fix strings

* Add test for the discovery feature

* Fix tests

* Add permission migrations

* Add relevant e2e tests

* Fix key alignment

* fix tests

* Fix lint

* Mock new migration

* Fix playwright prettier

* Add new section to delegated permissions

* Update snapshots

* Fix flakyness in playwright test

---------

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-27 13:13:20 +01:00
jachewz
e4f1ff75ba
fix admin_test not closing correct servers (#30531) 2025-03-26 19:06:44 +01:00
Chris Gibson
65256843f9
[GH-30056] Refactor SELECT statements in compliance_store.go (#30124)
* Change queries to use builder

* extract to tableSelectQuery

* Apply suggestions from code review

* update tests to check errors, lengths

* linting

* leverage s.toReserveCase

---------

Co-authored-by: Jesse Hallam <jesse@thehallams.ca>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-26 10:23:08 -03:00
Ben Schumacher
3b50ea2621
Skip flaky TestGetUserStatus/dnd_status_timed_restore_after_time_interval (#30534) 2025-03-25 08:09:47 +01:00
Agniva De Sarker
8faa8b2e56
MM-63545: Fix post reminder off-by-one error (#30553)
We used < which meant we missed sending
reminders created for that timestamp, because
the job runs on that exact time.

Using <= to fix that.

https://mattermost.atlassian.net/browse/MM-63545
```release-note
NONE
```
2025-03-25 11:09:42 +05:30
Julien Tant
cb89e5646e
[MM-62695] Extend property types for CPA (#30201)
* test: Add unit tests for custom profile attributes select options

* feat: Add custom profile attributes model with validation and constants

* refactor: Trim spaces from name and color in custom profile attribute select option constructor

* gofmt

* refactor: Fix typo in custom profile attributes select option function name

* feat: Add IsValid method to validate CustomProfileAttributesSelectOptions

* refactor: Replace map[string]bool with map[string]struct{} for key existence check

* refactor: Rename NewCustomProfileAttributeSelectOption to NewCustomProfileAttributesSelectOption

* feat: Add validation to prevent empty custom profile attribute options

* refactor: Add validation and creation methods for custom profile attributes

* feat: Add index number to validation error messages in custom profile attributes

* fix tests

* add default visibility

* feat: Add comprehensive test cases for custom profile attributes field validation

* fix: Update custom profile attributes map keys to use capitalized names

* feat: Add support for lowercase and title case keys in custom profile attributes map

* test: Add comprehensive test for NewCustomProfileAttributesSelectOptionFromMap

* feat: Add validation for custom profile attributes fields

* refactor: Update CustomProfileAttributesSelectOption constructor to prioritize ID parameter

* test: Add test cases for preserving IDs in custom profile attributes

* feat: Enhance ID validation and trimming in custom profile attributes

* don't do validation in constructor

* test: Add test case for preserving option IDs when patching select field

* improve test

* i18n

* refactor: Modify CustomProfileAttributesSelectOption to use lowercase JSON keys

* fix casing in custom profilte attributes test

* refactor: Use consistent "ValidateCPAField" in error messages for custom profile attributes

* use custom types rather than string

* lint

* fix api test

* refactor: Make color field optional in custom profile attributes

* style

* generic options

* removed unused i18n

* test: Add tests for NewCPAFieldFromPropertyField and CPAFieldToPropertyField

* test: Add test case for property field with empty attributes

* refactor: Cleanup whitespace and remove empty Attrs in custom profile attributes test

* test: Add test case for CPA field with empty attributes

* refactor: Improve custom profile attributes field handling and validation

* refactor: Move validateCustomProfileAttributesField to Validate method on CPAField struct

* use CPAField

* code style

* add validation and tests

* tests

* i18n

* err->appErr

* fix TestDeleteCPAField test

* i18n

* Add SAML and LDAP attr

* rename CustomProfileAttributes in method to CPA

* rename CPASortOrder method

* rearrange consts

* use Len test method

* sanitize and validate

* manage error the same way property field and value do

* fix: Update test error ID for custom profile attributes validation

* test: Update error ID expectations in custom profile attributes tests

* refactor: Convert CPAAttrs.SortOrder from string to int

* json uses float64

* feat: Add length validation for custom profile attribute option name and color

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-20 18:47:40 +00:00
Ben Schumacher
9b5d8d52bf
[MM-62427] Add message attachments validation (#30180)
* Add message attachments validation

* Add props validation

* Validate slack attachment fields

* Update tests and library usage

* Improve interactive dialog error for length checks

* Allow predefined colors for slack attachments

* Fix TestPostAction

* Use const for data source

* Add tests

* Cleanup unused props

* Add happy path tests

* lint fixes

* Add validation for PostActionOptions
2025-03-20 12:53:50 +01:00
Agniva De Sarker
5609489e86
MM-62900: Avoid redundant query for channelID while indexing file (#30289)
The file already has the ChannelID field. Therefore, we avoid querying
the database again. This sometimes causes errors in customer environments
where  there is noticeable replication lag, causing files not to be
indexed entirely.

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

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-20 11:46:44 +05:30
Agniva De Sarker
a51a8e9b60
MM-62964: Skip setting replica lag handle in case of an error (#30498)
Previously, we would set it to nil pointer which would eventually
cause a panic when ReplicaLagAbs/ReplicaLagTime would get called.

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

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-20 11:38:29 +05:30
Harrison Healey
3b9f9b209a
MM-63350 Add tests for inviting guest users to teams (#30448)
* MM-63350 Add tests for inviting guest users to teams

* Fix style issue

* Fix one more issue
2025-03-19 17:27:33 -04:00
Ben Schumacher
d7d8b4163e
[MM-63442] Fix GET /groups endpoint docs (#30473)
* Fix GET /groups endpoint docs

* Extend groups endpoint tests
2025-03-19 19:38:37 +01:00
Jesse Hallam
594e8d3171
MM-62159: Avoid SELECT * in channel_store_categories.go (#30424)
* MM-62159: Avoid SELECT * in channel_store_categories.go

- Added sidebarCategorySelectQuery field to SqlChannelStore struct
- Replaced SELECT * with explicit column selection in GetSidebarCategory and getSidebarCategoriesT functions
- Updated raw SQL query in addChannelToFavoritesCategoryT to use explicit column selection
- Made the implementation more resilient to schema changes

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* use sc alias, simplify

* MM-62159: Fix ambiguous ID column in sidebar category queries

- Modified sidebarCategorySelectQuery initialization to explicitly use "sc" table alias for all columns
- Prevents "Column 'Id' in field list is ambiguous" error when joining with other tables

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62159: Consistently use table aliases in sidebar categories queries

- Added 'sc' table alias to all sidebar category queries
- Ensures consistency and avoids ambiguous column errors in future joins

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>

* MM-62159: Replace 'sc' alias with full 'SidebarCategories' table name

- Replaced all instances of the 'sc' alias with the full table name 'SidebarCategories'
- Updated the SidebarCategories query builder to use the full table name
- Removed commented-out debug printf statement

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-19 10:49:19 -03:00
Agniva De Sarker
8eadf849bb
MM-60790: Prevent stemming in DB search when search term is a fully quoted string (#30214)
When a search term is a fully quoted string, we want to avoid
stemming if it is supported by the search backend.

For Postgres, it does provide a feature by which if we use the
"simple" search config, then no stemming is performed and an exact
match with the word is done without having to resort
to LIKE queries.

Unfortunately, for ES/OS this is not an option because
the message field is a text field, which means ES/OS will analyze it,
stem it and store it in its root form. Therefore, no exact match
can be possible with ES/OS.

The only solution here is to have yet another keyword field
for message which will store it in its raw form. But this
will effectively double the disk storage for post indices
and not a good design choice.

Ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html#avoid-term-query-text-fields

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

```release-note
NONE
```

* re-arrange the tests to run only on DB

```release-note
NONE
```

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-19 12:10:29 +05:30
Alejandro García Montoro
350714f390
Bump Go to v1.23.7 (#30455)
* Update Go version to v1.23.7

* Bump golangci-lint to a version supporting Go 1.23

* Fix golangci-lint warnings

Several rules from gosimple, revive and staticcheck linters were
failing:
- Redefinition of built-in identifiers (max, min, new, recover...)
- Use of printf-like functions with simple strings
- Check for nil slices, when len already takes it into account

* Trigger Build

* Trigger Build

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-17 14:22:07 +01:00
Christopher Poile
c049748b88
[MM-63314] Fix ClaimJob in HA environments (#30383)
* ClaimJob now returns newly claimed job

* internal code affected by change

* test changes required

* two branches: for mysql, use transaction; for postgres, use returning

* two branches: for mysql, use transaction; for postgres, use returning

* use same millis value for LastActivityAt and StartAt

* blank commit

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-14 10:24:26 -04:00
Ben Cooke
ccd8a60168
Plugin groups (#30320)
* add new pluginapi methods

* SAML login hook

* set ReAddRemovedMembers to true for plugin groups

* change to DoLogin signature for SAML
2025-03-13 12:00:15 -04:00
Arya Khochare
4fbfd84957
[MM-61691] Deleting drafts when permanently deleting a user (#30233)
* deleting drafts on permanently deleting user

* verified count of drafts before deleting

* i18n fix

* use ExecBuilder

* changed error message to specify user

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
2025-03-13 19:19:38 +05:30
Harshil Sharma
84fa496c69
Added missed license check for channel banner in patch channel API (#30445)
* Added missed license check for channel banner in patch channel API

* Extractced permission check function
2025-03-13 12:38:29 +05:30