Commit graph

1695 commits

Author SHA1 Message Date
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
Ben Cooke
eb967b6b6d
MM-61707 (#29606)
* updating maxattempts for ldap
2025-03-12 18:22:03 -04:00
Jesse Hallam
9fc83f24b5
MM-62161: Replace SELECT * in session_store.go (#30422)
* MM-62161: Replace SELECT * in session_store.go

- Replaced all SELECT * queries with explicit column selection
- Used query builder instead of raw SQL strings where possible
- Added reusable sessionSelectQuery in the store constructor
- Added comprehensive test for GetSessionsWithActiveDeviceIds

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

* Fix variable shadowing issues in session_store.go

Resolved variable shadowing by reassigning to the existing error variables instead of declaring new ones in scoped blocks.

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

* Fix code formatting in session_store test file

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-12 19:35:33 +00:00
Claudio Costa
7c25de2cff
[MM-63345] Address Go v1.23 incompatibility issues with plugins (#30386)
* Address Go v1.23 incompatibility issues with plugins

* Install multiple Go versions for compatibility tests

* Rename
2025-03-11 17:44:42 +00:00
Miguel de la Cruz
c5e6d9f570
Updates the property service and store method signatures (#30103)
* Updates the property service and store method signatures

Getters can now receive a `groupID` that narrows down the query if
present, so it's not necessary to check for the group ID on the
returning values from the outside layers.

The Search methods now receive the `groupID` and the `targetID`
explicitly as parameters, incentivizing the use of the indexes that
the underlying tables have on the searches.

* Fix tests

---------

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-10 14:26:47 +00:00
Scott Bishel
5fe7c36457
make sure RestrictSystemAdmin returns for all users access system console (#30384)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-03-08 08:13:19 -07:00
Claudio Costa
e549aaffb0
Fix incorrect error handling in api4.downloadJob (#30410) 2025-03-06 08:04:39 -06:00
Doug Lauder
dfca6c211d
MM-63327 Config setting for ServiceSettings.FrameAncestors (#30409)
* Add Embedding page to system console, with single setting for Frame Ancestors
2025-03-05 18:01:43 -05:00
Agniva De Sarker
a5d318cdfb
[AI assisted] MM-63304: Wrap around dqPtr while unmarshalling (#30371)
If the deadQueue was full, we would be incorrectly sending
the wrong index for dqPtr. Fixed that and added a test case.

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

```release-note
NONE
```
2025-03-04 13:36:04 +05:30
Ben Schumacher
e1336b24bf
Skip flaky test TestBusySet (#30363) 2025-02-27 16:59:49 +01:00
Devin Binnie
341186355d
[MM-62798][MM-63193] Restrict channel permissions on archived channels when viewing archived channels is disabled (#30314)
* [MM-62798][MM-63193] Restrict channel permissions on archived channels when viewing archived channels is disabled

* PR feedback

* PR feedback
2025-02-27 15:05:16 +00:00
Agniva De Sarker
ac10bb12a5
Revert "Bump Go version to 1.23.6 (#30242)" (#30359)
This reverts commit acbbd4c58d.
2025-02-27 14:58:51 +05:30
Harrison Healey
470123125a
MM-63205 Revert emoji store methods to return empty arrays instead of nil (#30337)
* MM-63205 Revert emoji store methods to return empty arrays instead of nil

* Update tests for getEmojiList

* Add case to TestGetEmojisByNames

* Update tests for searchEmoji and autocompleteEmoji
2025-02-26 15:40:52 -05:00
Devin Binnie
9f49403d0a
[MM-62687] Patch permission check to avoid modifying the system admin (#30292)
* [MM-62687] Patch permission check to avoid modifying the system admin

* Check for manage system first

* PR feedback

* Add another test

* Lint

* Fix test
2025-02-26 20:25:02 +00:00
Alejandro García Montoro
acbbd4c58d
Bump Go version to 1.23.6 (#30242)
* Bump Go version to 1.23.6

* Update CodeQL Github action as well

* Use server's Go version for CodeQL action

Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com>

* Empty commit to trigger CI

* 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

---------

Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-26 16:43:04 +01:00
enzowritescode
77ae2e2d6d
Fix doc comments and IDE complaint about ie. vs i.e. (#30340) 2025-02-26 08:17:56 -07:00
Harrison Healey
3902d00d0f
MM-61947 Run DND expiry job more often and round expiry time to match interval (#29938)
* MM-61947 Run DND expiry job more often and round expiry time to match interval

* Move comment to make it godoc-compatible

* Change truncateDNDEndTime to work with seconds

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-25 16:20:00 -05:00
Arya Khochare
e8ef26196c
Fixed errcheck issues in server/channels/app/permissions.go (#29064)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-02-25 10:49:28 +01:00
Harshil Sharma
6e738f489f
Channel banner sql migrations (#30274)
* Adde MySQL and Postgres migrations

* Replaced select * with column names

* removed all * from channel SQL store

* cleanup

* Fixed a duplicate column

* cleanup

* Added migrations and store support

* WIP

* used channelname slice in a missed place

* Handled patch

* Added app level tests

* Added API layer tests

* Added API layer tests

* WIP

* converted to query builder

* cleanupo

* added not null and default constraints

* Fixed test

* fixed file name

* review fixes

* review fixes

* updated migration file

* fixed text

* Review fixes
2025-02-25 14:52:15 +05:30
Agniva De Sarker
4e5cb16955
MM-62079: Using a cache prefix to isolate cache keys for each test (#30261)
```release-note
A new config setting CacheSettings.RedisCachePrefix has been added which can be used to add a prefix to all Redis cache keys.
```
2025-02-25 09:22:15 +05:30
Scott Bishel
806fce3030
MM-62760 - Allow Team Admins to view team email (#30170)
* allow team admins to view team email.

* Update server/channels/api4/team_test.go

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

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2025-02-24 11:05:17 -07:00
Doug Lauder
09ff43acc6
Remove channel export plugin from transitional plugins list. Channel export plugin is now prepackaged. (#30193)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-24 11:39:34 -05:00
Harshil Sharma
920b3301e5
[MM-63196] Channel sql store migrate select * to specific columns (#30255)
* Adde MySQL and Postgres migrations

* Replaced select * with column names

* removed all * from channel SQL store

* cleanup

* Fixed a duplicate column

* cleanup

* used channelname slice in a missed place

* WIP

* converted to query builder

* cleanupo

* Review fixes
2025-02-24 09:13:12 +05:30
Agniva De Sarker
fa9af97727
MM-63195: Enforce MFA requirement for non-self requests (#30290)
https://mattermost.atlassian.net/browse/MM-63195

```release-note
NONE
```
2025-02-22 12:54:52 +05:30
Agniva De Sarker
fd356b62b4
[AI assisted] MM-62837: (#30268)
We did not invalidate the cache after converting a user to bot.
That led to issues. See JIRA for more details.

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

```release-note
NONE
```
2025-02-20 21:45:44 +05:30
Claudio Costa
2f8c65a1ea
Fix flaky TestGetMattermostLog (#29890) 2025-02-19 08:56:56 -06:00
Devin Binnie
ce61ed8f52
[MM-55090] Threads created by users should not be auto-followed on reply by the creator when they've left the channel (#30181)
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2025-02-18 17:29:26 +00:00
Agniva De Sarker
32037706b5
MM-62960: Support both webhub iteration scopes properly (#30224)
When Channel iteration mode is enabled, we need to ensure that
channel scoped events do not fall through to the connIndex.All()
condition. This is possible because there are multiple hubs
in a given system. So a single event will flow through all of them
and in some hubs, a channel scoped event might not have any connections.

In that case, we need to stop processing further.

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

```release-note
NONE
```
2025-02-17 19:39:39 +05:30
Agniva De Sarker
e7a246c065
[AI assisted]: MM-62914: Added MFA authentication for plugin requests as well (#30160)
We wipe the token if MFA authentication is enabled. Also added a test case
to lock in the functionality.

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

```release-note
NONE
```
2025-02-17 12:20:21 +05:30
Agniva De Sarker
da7192246e
MM-62960: Improve webConn remove performance from hubConnectionIndex (#30178)
When we added iteration by channelID, this was a known tradeoff during that.
However, it has been observed that the regular connection removal function
creates considerable blocking of the processing loop, leading to high
CPU usage and API latencies.

To fix this, we add a reverse mapping of channelIDs to connections
and their positions in the slice. This helps us to remove the connection
from the slice without iteration.

Unfortunately, this still needs to iterate through all channelIDs
during invalidation of the channel member cache. However, the user
cache invalidation is not a regular activity. So it should be an acceptable
tradeoff to make.

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

```release-note
A new config knob ServiceSettings.EnableWebHubChannelIteration which allows a user to control the performance of websocket broadcasting. By default, this setting is turned off. If it is turned on, it improves the websocket broadcasting performance at the expense of poor performance when users join/leave a channel. It is not recommended to turn it on unless you have atleast 200,000 concurrent users actively using MM.
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-14 09:19:36 +05:30
Caleb Roseland
68c11e9ecb
MM-61375: Update file handling for bookmarks (#30034) 2025-02-13 17:11:13 -06:00
Caleb Roseland
2182b1eaf9
MM-62548: CPA Reordering - drag and drop (#30097) 2025-02-13 17:09:35 -06:00
Julien Tant
41e0f97176
Remove call for removed attribute Page (#30207) 2025-02-13 17:35:27 +00:00
Agniva De Sarker
1a58f923e0
[aider assisted] MM-61888: Add ClientSideUserIds field to MetricsSettings (#30127)
We add a new config setting to allow the admin to set a fixed
list of userIDs to track for all client side webapp metrics.

This gives the admin to get a deeper look at how the application
is behaving for a single user.

A new section in the system console is also added for the user
to edit this setting from the UI.

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

```release-note
A new config setting MetricsSettings.ClientSideUserIds is added
where you can set the user ids you want to track for client side webapp
metrics.
```

* fix lint errors

```release-note
NONE
```

* fixing tests

```release-note
NONE
```
2025-02-13 21:10:34 +05:30
Julien Tant
632a60b332
[MM-62553]+[MM-62554] Property Architecture: cursor based pagination (#30119)
* refactor: Replace pagination with cursor-based pagination for custom profile attributes

* remove pagination loop on property value retrieval for CPA

* add migrations to optimize pagination on property fields and values

* adapt test to remove pagination check

* update migrations list

* postgres: drop index concurrently

* concurrent index manipulation must be done outside of a Tx

* fix: Correct SQL index drop syntax from "OM" to "ON" in migration files

* test: Add CountForGroup test cases for property field store

* refactor: Add CountForGroup method to PropertyFieldStore interface and implementations

* Fix style and i18n

* feat: Add optional deleted property field filtering to CountForGroup method

* refactor: Update CountForGroup to support optional deleted property fields

* test: Add comprehensive tests for CountForGroup with includeDeleted parameter

* adapt test + gen layers

* rename property service method and set the includeDelete to false

* refactor: Remove redundant constant and use CustomProfileAttributesFieldLimit directly

* fix tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-13 15:23:50 +00:00
Miguel de la Cruz
f85a8c61a4
Adds websocket messages to Custom Profile Attributes (#30163)
* Adds websocket messages to Custom Profile Attributes

The app layer now fires a websocket event as part of the operations
over Custom Profile Attribute fields and values. It updates as well
the Patch method for CPA values so all the changes are commited as
part of the same transaction.

To be able to do this last operation, the change adds methods to
upsert CPA values in both the store and the property service.

* Fix i18n strings

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
2025-02-13 11:21:46 +00:00
Miguel de la Cruz
5ba80d51ae
Updates the property field and value update methods to use a single query for multiple entities (#30198)
* Updates the property field and value update methods to use a single query for multiple entities

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

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

---------

Co-authored-by: Miguel de la Cruz (aider) <miguel@ctrlz.es>
Co-authored-by: Julien Tant <785518+JulienTant@users.noreply.github.com>
2025-02-13 11:12:51 +00:00
Maria A Nunez
7efdcda20a
Update User Limits for unlicensed servers (#30134)
* Update user soft and hard limits

* Fix testt

* Fix test
2025-02-10 11:55:42 -05:00
Arya Khochare
f6c4bdf365
[MM-62149] Avoid SELECT * in emoji_store.go (#30082)
* refractored select sql queries

* rm unused makeStringArgs

* linting

* leverage builder pattern

---------

Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2025-02-10 12:02:50 -04:00
Ben Schumacher
0927ecb0f1
[MM-62517] Add audit logs to Support Packet (#29844) 2025-02-10 11:32:04 +01:00
Agniva De Sarker
3698808625
MM-62926: Fix standard logger redirection issue (#30137)
We were redirecting any logging happening via the Go standard logger
to our own mlog instance. The issue is that all those logs were happening
at LvlStdLog level which is higher than LvlDebug.

LvlStdLog is at 10, and LvlDebug is at 5. So unless a customer
sets the log level specifically to "stdlog" or sets up advanced
logging to specifically log for that level, no standard logs will
ever get logged.

We fix this by logging it at warn level. The reason for warn
is that mostly external libraries use this facility to log
out-of-band errors that could not be returned using standard
error returns.

I saw another plugin error which was logged similarly. This
was never surfaced before due to this bug.

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

```release-note
NONE
```
2025-02-08 22:28:04 +05:30
Arya Khochare
b11d536774
[MM-62152] Avoid SELECT * in oauth_store.go (#30080)
* refractored select queries

* test fail fix

* linting issues

* use builder pattern

* simplify GetAuthorizedApps

* revert to base behaviour

---------

Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2025-02-07 16:38:49 -04:00
Arya Khochare
50258a6510
[MM-62153] Avoid SELECT * in preference_store.go (#30081)
* refractored sql queries

* GetBuilder to Select Builder as preferences is slice (fix failing test)

* test: Add test for GetCategoryAndName preference method

* fix s/GetBuilder/SelectBuilder

* linting

* make mocks

* make store-layers

---------

Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2025-02-07 12:05:29 -04:00
Ibrahim Serdar Acikgoz
a3f22bd349
[MM-62004] update threads after a channel gets moved (#29624) 2025-02-07 15:20:13 +00:00
Jesse Hallam
7d9521d783
MM-62142: remove SELECT * from status store (round 2) (#30060)
* Revert "Revert "[MM-62142] Avoid SELECT * in status_store.go (#29610)" (#29985)"

This reverts commit d345e92136.

* add tests for StatusGet and StatusGetByIds

* handle NULL columns in the Status Store

* simplify status store

* more builder simplifications and tests

* expose GetQueryPlaceholder

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-06 12:36:31 -04:00
Agniva De Sarker
c4718e4542
MM-60211: Bump dependencies (#30005)
https://mattermost.atlassian.net/browse/MM-60211
```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-06 21:48:08 +05:30
Christopher Poile
50c7f1df12
[MM-62876] Bulk export warnings (#30105)
* err -> appErr

* record warnings in job.Data, and output them to warnings.txt

* tests
2025-02-06 10:34:34 -05:00
Harshil Sharma
35e776d805
Removed Elasticsearch and Opensearch channel index schedma check (#30102) 2025-02-06 11:50:37 +05:30
Christopher Poile
1ce29f8466
[MM-60989] Add SelectBuilderCtx to simplify db code (#29988)
* add SelectBuilderCtx; change the few calls where it's appropriate to use

* tests (wip)

* tests improved

* use SelectCtx's own WithTimeout

* improve tests based on PR feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-05 16:06:43 -05:00
Jesse Hallam
f08580ec09
t.Skip flaky TestUpdateOAuthApp (#30118)
Fixes: https://mattermost.atlassian.net/browse/MM-62895
2025-02-05 17:25:51 +00:00
Julien Tant
bcc395d139
[MM-62552] Custom Profile Attributes: use json.RawMessage for the value. (#29989)
* refactor: Move property value sanitization to model layer

* feat: Add value sanitization for custom profile attributes

* refactor: Update custom profile attributes to use json.RawMessage

* refactor: Update patchCustomProfileAttribute to handle json.RawMessage directly

* refactor: Refactor custom profile attributes handler with improved validation

* refactor: Rename `patchCustomProfileAttribute` to `patchCPAValues`

* refactor: Replace ReturnJSON with json.NewEncoder and add error logging

* feat: Add encoding/json import to property_value.go

* refactor: Update property value tests to use json.RawMessage

* fix: Convert string value to json.RawMessage in property value test

* fix: Convert string literals to json.RawMessage in property value tests

* fix: Add missing encoding/json import in custom_profile_attributes.go

* fix: Preserve JSON RawMessage type in listCPAValues function

* fix: Update custom profile attributes test to use json.RawMessage

* feat: Add json import to custom_profile_attributes_test.go

* refactor: Update ListCPAValues and PatchCPAValues to use json.RawMessage

* refactor: Rename `actualValue` to `updatedValue` in custom profile attributes test

* refactor: Improve user permission and audit logging for custom profile attributes patch

* refactor: Optimize CPA field lookup by using ListCPAFields() and map

* fix: Correct user ID reference in custom profile attributes patch endpoint

* refactor: Change patchCPAValues to use map[string]json.RawMessage for results

* refactor: format and fix tests

* test: Add comprehensive unit tests for sanitizePropertyValue function

* test: Add test case for invalid property value type

* feat: Use `model.NewId()` to generate valid IDs in custom profile attributes tests

* refactor: Replace hardcoded IDs with dynamic variables in custom profile attributes test

* refactor: restore variable name

* refactor: drop undesired changes

* chore: refresh app layers

* feat: Update API definition to support string or string array values for custom profile attributes

* test: Add test cases for multiselect custom profile attribute values

* test: Add tests for multiselect custom profile attribute values

* test: Isolate array value test in separate t.Run

* test: Add test case for multiselect array values in custom profile attributes

* refactor: Move array value test from TestCreateCPAField to TestPatchCPAValue

* test: Update custom profile attributes test assertions

* test: add test case for handling array values in GetCPAValue

* test: Add array value tests for property value store

* refactor(store): no need to convert to json the rawmessage

* chore: lint

* i18n

* use model to interface with sqlx

* fix: Allow empty strings for text, date, and select profile attributes

* refactor: Filter out empty strings in multiselect and multiuser fields

* refactor: Update multiuser field sanitization to validate and error on invalid IDs

* refactor: Simplify sanitizePropertyValue function with reduced code duplication

* fix: Allow empty user ID in custom profile attribute sanitization

* refactor: Convert comment-based subtests to nested t.Run in TestSanitizePropertyValue

* refactor: Convert comment-based subtests to nested t.Run tests in TestSanitizePropertyValue

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-05 17:21:22 +00:00
Christopher Poile
6560b4c0cf
[MM-62845] Fix: Compliance export download link fails from S3 when using a dedicated file store (#30092)
* add ExportZipReader and use that for job exports

* fix legacy code to use ExportFileReader
2025-02-05 07:31:07 -05:00
Christopher Poile
3a73b517e2
[MM-62775] Fix: Bulk export not completing (#30044)
* do not error on exportFile error

* add tests for local and s3 storage exporting with missing file

* linting

* fix attachment path validation in mmctl
2025-02-04 17:56:11 -05:00
Caleb Roseland
f52e08754c
MM-62050: restrict channel bookmarks in archived channels (#29490) 2025-02-04 15:10:32 -06:00
Agniva De Sarker
ae9e6174e5
[AI assisted]: Improve system console statistics performance (#29899)
```release-note
NONE
```

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
2025-02-04 21:54:01 +05:30
Claudio Costa
316cde2569
[MM-62191] Remove disintegration/imaging dependency (#29657)
* Remove disintegration/imaging dependency

* Simplify FillCenter logic

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-02-03 11:04:00 +05:30
Agniva De Sarker
341f919fa8
MM-62782: Bumping minimum Postgres version to 13 (#30039)
As discussed in https://docs.mattermost.com/install/prepare-mattermost-database.html#minimum-supported-version-policy

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

```release-note
Minimum postgres version has been bumped to 13.
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-31 09:57:35 +05:30
Scott Bishel
369b9fa96b
Prompt Team Admin before joining private channel (#29955)
* Prompt Team Admin before joining private channel

* fix and implement prompt when team admin joins via channel link

* update premission check and unit tests

* remove comment

* clean up some code

* update check to fix E2E tests
2025-01-30 08:21:09 -07:00
Scott Bishel
f2af360401
MM-62500 - Apply Delete check on commands (#29896)
* apply delete check on commands, add tests

* combine tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-30 08:20:36 -07:00
Miguel de la Cruz
8c3490b3d8
Skip racy test on api4.TestCreatePost (#30029)
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-30 11:07:10 +00:00
Miguel de la Cruz
9f172fed70
Update the property field model to interface with SQLX (#29987)
* Update the property field model to interface with SQLX

* Fix tests
2025-01-30 03:32:24 +00:00
Claudio Costa
528026d6fb
Use CreateConnectedWebSocketClient test util (#30036) 2025-01-29 07:58:43 -06:00
Jesús Espino
f1acdce42c
Removing opentracing (#29965)
* Removing opentracing

* Fixing CI
2025-01-29 07:45:13 +01:00
Doug Lauder
565c8aa42d
Audit usage of the searchPosts API (#29909)
* Audit calls to searchPosts API

* Update server/public/model/post_search_results.go

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>

* Update server/public/model/post_search_results.go

* Update server/public/model/post_search_results.go

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-28 22:21:05 -05:00
Agniva De Sarker
afbd9d64c3
[AI assisted]: MM-62295: Search and index archived channels as well. (#29796)
We add a new field delete_at in the channels template.

This field is then searched in the SearchChannels function.

Also added tests to verify that archived channels are searched
properly, and also indexed correctly.

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

```release-note
- Now archived channels are searchable with ES/OS if TeamSettings.ExperimentalViewArchivedChannels is enabled.
- If there are old channels which were archived before a bulk index was run, users would need to purge indexes, and do bulk index again. Because those old archived channels are removed from the index when a bulk index is run.
```


Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-28 19:44:55 +05:30
Devin Binnie
64070b0780
[MM-62541] Exclude files not attached to a post from the file count for a channel (#29976)
* [MM-62541] Exclude files not attached to a post from the file count for a channel

* Added test to ensure that we only grab files with a post id
2025-01-28 08:17:11 -05:00
Ben Schumacher
d8d65b8ec7
[MM-62079] Rewrite TestCreatePost (#29903) 2025-01-28 10:02:03 +01:00
Julien Tant
8b5a3e6217
[MM-62502] Ensure MFA Check on search routes (#29880) 2025-01-27 18:03:16 +00:00
Scott Bishel
b26c43e716
Permission changes (#29570)
* update permission mistakes

* add getAnalytics to TeamStatistics

* add PermissionGetAnalytics to ReadTeamStatistics

* add mocks for migrations

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-27 16:28:27 +00:00
Seiya Homma
a5faf9e6e3
[MM-61775] Fix errcheck issues in server/channels/app/platform/web_broadcast_hook.go (#29514)
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2025-01-27 11:26:28 +00:00
Christopher Poile
737bed311c
MM-60115, MM-62436, MM-62493: Compliance export downloads from local and s3; e2e tests (#29806)
* add ZipReader method to filestore and file/s3 backends

to merge

to merge

* add WriteStreamResponse as an alternative to WriteFileResponse

* add generated layers

* enable download link; download job endpoint now streams export dir zips

* fix MM-62493

* re-enable e2e tests--we have download links, folks

* Add tests for ZipReader in filestore and s3store

* remove unnecessary error return on ZipReader

* little cleanup

* improve tests; some refactoring: s.Nil(err) -> s.NoError(err)

* blank commit

* backwards compatability for pre-10.5 job downloads

* compress file response; better errors; better comments; PR comments

* update generated app layers

* improve/widen tests; improve comments; simplify localstore ZipReader

* regenerate layers

* follow GoDoc conventions

* update generated layers

* remove unnecessary comment

* in jobs/job-id/download, clean exportDir before sending to ZipReader

* better comments; add an error return on ZipReader

* improve file permissions

* adjust tests for new error returns

* linting

* i18n
2025-01-27 09:28:07 +05:30
Jesse Hallam
d345e92136
Revert "[MM-62142] Avoid SELECT * in status_store.go (#29610)" (#29985)
This reverts commit 84a83a1e0f.
2025-01-23 18:01:18 +01:00
Julien Tant
b41b968eb8
restrict access to channel converstion to public for non team admin+ (#29819) 2025-01-23 09:42:20 -07:00
Matheus
291fe10784
[MM-62145] Migrating SELECT * queries for system_store.go (#29821)
* Step 1: Migrate any SELECT * queries written as strings into builder queries.

* Step 2: Migrate any instances of SELECT * into explicitly enumerating the needed columns

* revert `GetByName` to read from master as opposed to master.

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-23 11:06:36 -04:00
Claudio Costa
835b276ff0
[MM-62437] Fix flakyness in channel bookmark tests (#29893)
* Fix flakyness in channel bookmark tests

* Use existing util to initialize client

* Update server/channels/api4/apitestlib.go

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>

* Remove redundant close

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-23 10:16:21 -04:00
Sarthak0714
106cd66d69
migrate select * in thread_store.go (#29755)
* migrate select * in thread_store.go

* fix trailing whitespace

* reverted to single query

* maintained err handling pattern

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-23 10:10:17 -04:00
Miguel de la Cruz
7fb6901ad1
Adds Custom Profile Attributes API endpoints license check (#29906)
* Adds Custom Profile Attributes feature license and API endpoints check

* Fix linter

* Remove the specific license feature and fallback to checking for license presence

* Add translation

* Update the checks and tests to enable endpoints only for Enterprise licenses

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-23 09:50:43 +01:00
enzowritescode
077d0872e3
Fix LogAuditRecWithLevel doc comment and fix typo (#29980) 2025-01-22 21:39:31 -07:00
Christopher Poile
e8eb279874
[MM-60888] Fix: Retention can cause unrelated files to be deleted (#29897)
* fix for deleting non-bulk export files and directories

* add job worker setup and running to helper_test.go

* add infrastructure for e2e testing of workers; test ExportDelete

* linting

* use retention days in test instead of magic number
2025-01-22 15:15:33 -05:00
Arya Khochare
84a83a1e0f
[MM-62142] Avoid SELECT * in status_store.go (#29610)
* SELECT * to query builder

* execBuilder, manual column name and one more select * remaining instance

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-22 11:59:41 -04:00
Christopher Poile
c205398040
[MM-60687] Log DoActionRequest requests to INFO (#29952)
* log DoActionRequest requests to INFO

* make generated
2025-01-21 20:02:39 -05:00
Agniva De Sarker
05cdb36886
MM-49353: Setup intermediate signal handlers for plugin shutdown (#28653)
There are several steps that a server runs through inside (*Server).Start
after ch.initPlugins() till the signal handler is reached which handles
the server shutdown procedure.

The issue arises when the server is shutdown after ch.initPlugins() completes
but before (*Server).Start finishes. In that case, the plugins are all started
but they won't be shut down cleanly.

To fix this edge-case, we set up an intermediate signal handler, which
attaches itself as soon as ch.initPlugins is finished, allowing us to run
the cleanup code in case the shutdown happens before (*Server).Start finishes.

And when we do reach the main signal handler, we don't need this intermediate
handler any more. So we just reset the handlers and use the main signal handler
which takes care of shutting down the whole server.

Note: This is still not 100% bug-proof because ch.initPlugins() will initialize
_all_ plugins, and the shutdown can happen just after one plugin is initialized.
To handle that case will require the need to set up signal handlers after every
plugin init which feels like overkill to me.

A sample flow diagram to visualize better:

Edge-case
server.Start()
|
ch.initPlugins()
|
<ctrl-c>
|
execute signal handler, os.Exit(1)

Happy-path
server.Start()
|
ch.initPlugins()
|
server.Start() finished
|
reset old signal handler
|
setup main signal handler
|
server runs on as usual until shutdown

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

```release-note
NONE
```
2025-01-21 11:15:19 +05:30
Uday Rana
7e912573da
[GH-29548] Avoid SELECT * in tokens_store.go (#29558)
* migrate Token Store GetByToken query to SQLBuilder

* explicitly enumerate columns, factor out query into constructor

* fix syntax error

* fix error handling

* spread args... instead of passing the array as a single param

* fix MySQL by casing columns correctly

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2025-01-21 00:20:04 -04:00
Claudio Costa
16381bf7a4
Fix flaky TestImportValidatePostImportData (#29891) 2025-01-20 09:34:10 -06:00
Agniva De Sarker
cb75a20c54
MM-61904: Make reliable websockets work in HA (#29489)
We do a cluster request to get the active and dead queues
from other nodes in the cluster to sync any missing
information.

We check the dead queue in the other nodes to see
if there's been any message loss or not. Accordingly,
we send just the active queue or both active and dead queues.

There's still an edge case that is left out where
a client could have potentially connected and reconnected
to multiple nodes leaving multiple active queues
in multiple nodes. We don't handle this scenario
because then potentially we need to create
a slice of sendQueueSize * number_of_nodes. And then
this can happen again, leading to an infinite increase
in sendQueueSize.

We leave this edge-case to Redis, acknowledging
a limitation in our architecture.

In this PR, when there's no message loss, we just
take the active queue from the last node it connected
to.

And if there's message loss where the client's
seqNum is within the last node's dead queue, we also
handle that.

But if there's severe message loss where the client's
seqNum falls within the dead queue of another node, then
we just send the data from that node to reconstruct the
data as much as possible. It could be possible to set
a new connection ID in this case, but this involves
more data transfer always from all nodes and recomputing
the state in the requestor node.

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

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-17 11:11:32 +05:30
Rahim Rahman
540408545a
feat(MM-61865): Add mobile client content load network metrics (#29601)
* MM-61865: Add mobile client content load network metrics

* added new common label

* renaming from MobileClientContentLoad to MobileClientNetworkRequests
* content_load_group => network_request_group

* refactor more NetworkRequest-* changes

* replace contentLoadGroup to networkRequestGroup

* new metrics elapsedTime

* Refactor urlCount to totalRequests

* add averageSpeed metric
* replace contentLoadGroup with networkRequestGroup
* use h.Labels vs commonLabels for network_request_group

* add agent

* add effective latency metrics

* add total parallel requests & total sequential

* mocks generated by mockery

* did a bit of cleanup and sorting

* formatting

* updated the AcceptedNetworkRequestGroups

* cleanup and sorting
2025-01-16 11:03:41 -07:00
Jesse Hallam
c3ff2c5129
s/u./Users./ (#29817)
Within the Users and Groups store, converge on just naming the `Users`
table instead of sometimes aliasing it and sometimes not. This makes an
informal, but unambiguous interface when sharing logic between stores,
and simplifies the next step of refactoring away from `Users.*` queries.

Relates-to: MM-62158
2025-01-15 06:32:17 -08:00
Seiya Homma
20e9c6aa3e
[MM-62147] Avoid SELECT * in channel_store.go (#29776)
* Resolve backward compatibility issues.

* Fix code
2025-01-14 09:41:44 +05:30
kasyap dharanikota
d3c972897e
migrate queries in scheme_store.go (#29687)
* migrate queries in scheme_store.go

* fix linting issues

---------

Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2025-01-13 15:29:43 -04:00
Ben Schumacher
8d4bf4bae0
[MM-54288] Support Packet V2 (#29403) 2025-01-13 20:23:09 +01:00
Miguel de la Cruz
ca34c6a03f
Custom profile attributes field endpoints (#29662)
* Adds the main Property System Architecture components

This change adds the necessary migrations for the Property Groups,
Fields and Values tables to be created, the store layer and a Property
Service that can be used from the app layer.

* Adds Custom Profile Attributes endpoints and app layer

* implement get and patch cpa values

* run i18n-extract

* Update property field type to use user instead of person

* Update PropertyFields to allow for unique nondeleted fields and remove redundant indexes

* Update PropertyValues to allow for unique nondeleted fields and remove redundant indexes

* Use StringMap instead of the map[string]any on property fields

* Add i18n strings

* Revert "Use StringMap instead of the map[string]any on property fields"

This reverts commit e2735ab0f8.

* Cast JSON binary data to string and add todo note for StringMap use

* Add mocks to the retrylayer tests

* Cast JSON binary data to string in property value store

* Check for binary parameter instead of casting to string for JSON data

* Fix bad merge

* Check property field type is one of the allowed ones

* Avoid reusing err variable to be explicit about the returned value

* Merge Property System Migrations into one file

* Adds NOT NULL to timestamps at the DB level

* Update stores to use tableSelectQuery instead of a slice var

* Update PropertyField model translations to be more explicit and avoid repetition

* Update PropertyValue model translations to be more explicit and avoid repetition

* Use ExecBuilder instead of ToSql&Exec

* Update property field errors to add context

* Ensure PerPage is greater than zero

* Update store errors to give more context

* Use ExecBuilder in the property stores where possible

* Add an on conflict suffix to the group register to avoid race conditions

* Remove user profile API documentation changes

* Update patchCPAValues endpoint and docs to return the updated information

* Merge two similar error conditions

* Use a route function for ListCPAValues

* Remove badly used translation string

* Remove unused get in register group method

* Adds input sanitization and validation to the CPA API endpoints

* Takes login outside of one test case to make it clear it affects multiple t.Runs

* Fix wrap error and return code when property field has been deleted

* Fix receiver name

* Adds comment to move the CPA group ID to the db cache

* Set the PerPage of CPA fields to the fields limit

* Update server/channels/app/custom_profile_attributes_test.go

Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>

* Standardize group ID access

* Avoid polluting the state between tests

* Use specific errors for the retrieval of CPA group

---------

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
2025-01-13 18:12:38 +01:00
Harshil Sharma
6e5a67caec
Feature edit attachments (#29769)
* Updated patch/update post API to allow file modification (#29447)

* WIP

* WIP

* Atatched new files ton post

* WIP: deleting removed files

* Deleted removed files and invalidated file metadata cache

* removed file ignore logif from update post API

* Added TestFindExclusives

* Added tests for DeleteForPostByIds

* Added app layer tests

* Added tests

* Added API level tests

* test enhancements

* Fixed a test

* Edit history include file metadata (#29505)

* Send file metadata in edit history metadata

* Added app tests

* Added store tests

* Added tests for populateEditHistoryFileMetadata{

* Added cache to avoid repetitigve DB calls for edits with only message changes

* Added API tests

* i18m fix

* removed commented code

* Improved test helper

* Show attachments in edit history RHS (#29519)

* Send file metadata in edit history metadata

* Added app tests

* Added store tests

* Added tests for populateEditHistoryFileMetadata{

* Added cache to avoid repetitigve DB calls for edits with only message changes

* Added API tests

* i18m fix

* WIUP: displa files in edit

* removed commented code

* Displayed file in edit history

* Handled file icon

* Fixed closing history component on clicking on file

* Simplified selector

* Simplified selector

* Improved test helper

* Disabled action menu on edit history file

* Added tests

* Improved selector

* Updated snapshot

* review Fixes

* restructured componnets

* Updated test

* Updated test

* Restore post api (#29643)

* Restore post version API WIP

* Undelete files WIP

* Added store tests

* Created post restore API

* Updated updatepost safeUpdate signature

* review fixex and improvements

* Fixed an app test

* Added API laer tests

* Added API tests and OpenAPI specs

* Fixed a typo

* Allow editing files when editing posts (#29709)

* WIP - basic view files when editing post

* Cleanup

* bg color

* Added text editor tests for files

* WIP

* WIP

* removed debug log

* Allowed admin to add and remove files on someone else's post

* Handled drafts and scheduled posts

* linter fixes

* Updated snapshot

* server test fix

* CI

* Added doc

* Restore post api integration (#29719)

* WIP - basic view files when editing post

* Cleanup

* bg color

* Added text editor tests for files

* WIP

* WIP

* removed debug log

* Allowed admin to add and remove files on someone else's post

* Handled drafts and scheduled posts

* linter fixes

* Updated snapshot

* server test fix

* Used new API to restore post

* handled edut limit and undo

* lint fix

* added comments

* Fixed edit post item tests

* Fixed buttons

* Aded snapshots

* fix test

* Updated snapshot

* Minor fixes

* fixed snapshot

* Edit file dnd area (#29763)

* dnd wip

* DND continued

* Supported multiple unbind dragster funcs

* lint fixes

* Got center channel file drop working when editing a post

* file dnd working with center channel and rhs

* file dnd working with center channel and rhs

* removed unneeded stopPropogation calls

* cleanup

* DND overlay fix

* Lint fix

* Advanced text editor test updates for file upload overlay

* fixed use upload hook tests

* Updated some more snapshots

* minor cleanup

* Updated i18n

* removed need of array for dragster unbind events

* lint fixes

* edit history cursor

* Fixed bugu causing faliure to delete empty posts (#29778)

* Files in restore confirmation (#29781)

* Added files to restore post confirmation dialog

* Fixed post restore toast colors

* Fixed restore bug

* Fixed restore confirmation toast tests

* a11y improvement and modal width fix

* Edit attachment misc fixes (#29808)

* Removed single image actions in restore post confirmation dialog

* Fixed file drop overlay size and position

* Made edit indiator accessible

* Lint fix

* Added bunch of more tests

* ANother test migrated from enzyme to react testing library

* More test enhancements

* More test enhancements

* More test enhancements

* lint fixes

* Fixed  a test

* Added missing snapshots

* Test fixes
2025-01-13 18:16:56 +05:30
Miguel de la Cruz
ecdce71fc4
Adds the main Property System Architecture components (#29644)
* Adds the main Property System Architecture components

This change adds the necessary migrations for the Property Groups,
Fields and Values tables to be created, the store layer and a Property
Service that can be used from the app layer.

* Update property field type to use user instead of person

* Update PropertyFields to allow for unique nondeleted fields and remove redundant indexes

* Update PropertyValues to allow for unique nondeleted fields and remove redundant indexes

* Use StringMap instead of the map[string]any on property fields

* Add i18n strings

* Revert "Use StringMap instead of the map[string]any on property fields"

This reverts commit e2735ab0f8.

* Cast JSON binary data to string and add todo note for StringMap use

* Add mocks to the retrylayer tests

* Cast JSON binary data to string in property value store

* Check for binary parameter instead of casting to string for JSON data

* Check property field type is one of the allowed ones

* Avoid reusing err variable to be explicit about the returned value

* Merge Property System Migrations into one file

* Adds NOT NULL to timestamps at the DB level

* Update stores to use tableSelectQuery instead of a slice var

* Update PropertyField model translations to be more explicit and avoid repetition

* Update PropertyValue model translations to be more explicit and avoid repetition

* Use ExecBuilder instead of ToSql&Exec

* Update property field errors to add context

* Ensure PerPage is greater than zero

* Update store errors to give more context

* Use ExecBuilder in the property stores where possible

* Add an on conflict suffix to the group register to avoid race conditions

* Remove badly used translation string

* Remove unused get in register group method

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-01-13 11:41:44 +00:00
Arya Khochare
d2b334e605
Fixed errcheck issues in server/channels/app/server.go (#29425)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2025-01-13 12:06:40 +01:00
Harrison Healey
cc33287dde
Skip flaky tests (#29773) 2025-01-13 09:42:54 +01:00
Christopher Poile
aba4434dab
MM-59966 - Compliance Export overhaul - feature branch (#29789)
* [MM-59089] Add a compliance export constant (#27919)

* add a useful constant

* i18n

* another constant

* another i18n

* [MM-60422] Add GetChannelsWithActivityDuring (#28301)

* modify GetUsersInChannelDuring to accept a slice of channelIds

* add GetChannelsWithActivityDuring

* add compliance export progress message; remove unused custom status

* linting

* tests running too fast

* add batch size config settings

* add store tests

* linting

* empty commit

* i18n changes

* fix i18n ordering

* MM-60570 - Server-side changes consolidating the export CLI with server/ent code (#28640)

* add an i18n field; add the CLI's export directory

* int64 -> int

* Add UntilUpdateAt for MessageExport and AnalyticsPostCount

to merge

* remove now-unused i18n strings

* add TranslationsPreInitFromBuffer to allow CLI to use i18n

* use GetBuilder to simplify; rename TranslationsPreInitFromFileBytes

* [MM-59089] Improve compliance export timings (#1733 - Enterprise repo)

* MM-60422 - Performance and logic fixes for Compliance Exports (#1757 - Enterprise repo)

* MM-60570 - Enterprise-side changes consolidating the export CLI with server/ent code (#1769 - Enterprise repo)

* merge conflicts; missed file from ent branch

* MM-61038 - Add an option to sqlstore.New (#28702)

remove useless comment

add test

add an option to sqlstore.New

* MM-60976: Remove RunExport command from Mattermost binary (#28805)

* remove RunExport command from mattermost binary

* remove the code it was calling

* fix i18n

* remove test (was only testing license, not functionality)

* empty commit

* fix flaky GetChannelsWithActivityDuring test

* MM-60063: Dedicated Export Filestore fix, redo of #1772 (enterprise) (#28803)

* redo filestore fix #1772 (enterprise repo) on top of MM-59966 feature

* add new e2e tests for export filestore

* golint

* ok, note to self: shadowing bad, actually (when there's a defer)

* empty commit

* MM-61137 - Message export: Support 7.8.11 era dbs (#28824)

* support 7.8.11 era dbs by wrapping the store using only what we need

* fix flaky GetChannelsWithActivityDuring test

* add a comment

* only need to define the MEFileInfoStore (the one that'll be overridden)

* blank commit

* MM-60974 - Message Export: Add performance metrics (#28836)

* support 7.8.11 era dbs by wrapping the store using only what we need

* fix flaky GetChannelsWithActivityDuring test

* add a comment

* only need to define the MEFileInfoStore (the one that'll be overridden)

* performance metrics

* cleanup unneeded named returns

* blank commit

* MM-60975 - Message export: Add startTime and endTime to export folder name (#28840)

* support 7.8.11 era dbs by wrapping the store using only what we need

* fix flaky GetChannelsWithActivityDuring test

* add a comment

* only need to define the MEFileInfoStore (the one that'll be overridden)

* performance metrics

* output startTime and endTime in export folder

* empty commit

* merge conflict

* MM-60978 - Message export: Improve xml fields; fix delete semantics (#28873)

* support 7.8.11 era dbs by wrapping the store using only what we need

* fix flaky GetChannelsWithActivityDuring test

* add a comment

* only need to define the MEFileInfoStore (the one that'll be overridden)

* performance metrics

* output startTime and endTime in export folder

* empty commit

* add xml fields, omit when empty, tests

* fix delete semantics; test (and test for update semantics)

* clarify comments

* simplify edited post detection, now there's no edge case.

* add some spacing to help fast running tests

* merge conflicts/updates needed for new deleted post semantics

* linting; fixing tests from upstream merge

* use SafeDereference

* linting

* stronger typing; better wrapped errors; better formatting

* blank commit

* goimports formatting

* fix merge mistake

* minor fixes due to changes in master

* MM-61755 - Simplifying and Support reporting to the db from the CLI (#29281)

* finally clean up JobData struct and stringMap; prep for CLI using db

* and now simplify using StringMapToJobDataWithZeroValues

* remove unused fn

* create JobDataExported; clean up errors

* MM-60176 - Message Export: Global relay cleanup (#29168)

* move global relay logic into global_relay_export

* blank commit

* blank commit

* improve errors

* MM-60693 - Refactor CSV to use same codepath as Actiance (#29191)

* move global relay logic into global_relay_export

* blank commit

* refactor (and simplify) ExportParams into shared

* blank commit

* remove unused fn

* csv now uses pre-calculated joins/leaves like actiance

* improve errors

* remove nil post check; remove ignoredPosts metric

* remove unneeded copy

* MM-61696 - Refactor GlobalRelay to use same codepath as Actiance (#29225)

* move global relay logic into global_relay_export

* blank commit

* refactor (and simplify) ExportParams into shared

* blank commit

* remove unused fn

* csv now uses pre-calculated joins/leaves like actiance

* remove newly unneeded function and its test. goodbye.

* refactor GetPostAttachments for csv + global relay to share

* refactor global_relay_export and fix tests (no changes to output)

* improve errors

* remove nil post check; remove ignoredPosts metric

* remove unneeded copy

* remove unneeded nil check

* PR comments

* MM-61715 - Generalize e2e to all export types 🤖  (#29369)

* move global relay logic into global_relay_export

* blank commit

* refactor (and simplify) ExportParams into shared

* blank commit

* remove unused fn

* csv now uses pre-calculated joins/leaves like actiance

* remove newly unneeded function and its test. goodbye.

* refactor GetPostAttachments for csv + global relay to share

* refactor global_relay_export and fix tests (no changes to output)

* improve errors

* remove nil post check; remove ignoredPosts metric

* remove unneeded copy

* remove unneeded nil check

* PR comments

* refactor isDeletedMsg for all export types

* fix start and endtime, nasty csv createAt bug; bring closer to Actiance

* align unit tests with new logic (e.g. starttime / endtime)

* refactor a TimestampConvert fn for code + tests

* bug: pass templates to global relay (hurray for e2e tests, otherwise...)

* add global relay zip to allowed list (only for tests)

* test helpers

* new templates for e2e tests

* e2e tests... phew.

* linting

* merge conflicts

* unexport PostToRow; add test helper marker

* cleanup, shortening, thanks to PR comments

* MM-61972 - Generalize export data path - Actiance (#29399)

* extract and generalize the export data generation functions

* finish moving test (bc of previous extraction)

* lift a function from common -> shared (to break an import cycle)

* actiance now takes general export data, processes it into actiance data

* bring tests in line with correct sorting rules (upadateAt, messageId)

* fixups, PR comments

* turn strings.Repeat into a more descriptive const

amended: one letter fix; bad rebase

* MM-62009 - e2e clock heisenbug (#29434)

* consolidate assertions; output debuggable diffs (keeping for future)

* refactor test output generator to generators file

* waitUntilZeroPosts + pass through until to job = fix all clock issues

* simplify messages to model.NewId(); remove unneeded waitUntilZeroPosts

* model.NewId() -> storetest.NewTestID()

* MM-61980 - Generalize export data path - CSV (#29482)

* simple refactoring

* increase sleep times for (very) rare test failures

* add extra information to the generic export for CSV

* adj Actiance to handle new generic export (no difference in its output)

* no longer need mergePosts (yay), move getJoinLeavePosts for everyone

* adjust tests for new csv semantics (detailed in summary)

* and need to add the new exported data to the export_data_tests

* rearrange csv writing to happen after data export (more logical)

* linting

* remove debug statements

* figured out what was wrong with global relay e2e test 3; solid now

* PR comments

* MM-61718 - Generalize export data path - Global Relay (#29508)

* move global relay over to using the generalized export data

* performance pass -- not much can be done

* Update server/enterprise/message_export/global_relay_export/global_relay_export.go

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

---------

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

* MM-62058 - Align CSV with Actiance (#29551)

* refactoring actiance files and var names for clarity

* bug found in exported attachments (we used to miss some start/ends)

* changes needed for actiance due to new generic exports

* bringing CSV up to actiance standards

* fixing global relay b/c of new semantics (adding a note on an edge case)

* aligning e2e tests, adding comments to clarify what is expected/tested

* necessary changes; 1 more test for added functionality (ignoreDeleted)

* comment style

* MM-62059 - Align Global Relay with Actiance/CSV; many fixes (#29665)

* core logic changes to general export_data and the specific export paths

* unit tests and e2e tests, covering all new edge cases and all logic

* linting

* better var naming, const value, and cleaning up functions calls

* MM-62436 - Temporarily skip cypress tests that require download link (#29772)

---------

Co-authored-by: Claudio Costa <cstcld91@gmail.com>
2025-01-10 16:56:02 -05:00
enzowritescode
0c213eae9e
Reduce number of IDE warnings in permissions_migrations.go (#29605)
* Reduce number of IDE warnings in permissions_migrations.go

* Fix comment language
2025-01-09 11:33:03 -07:00
Ben Schumacher
e8beefd423
Remove duplicate SAML login error message (#29767) 2025-01-09 12:41:11 +01:00
Agniva De Sarker
4265df8a07
MM-62079: Fix permissions being reset properly (#29574)
The default role permissions weren't being saved
to a separate variable which would have not restored
them properly. This was a problem in various other
tests, potentially causing side-effects in other
flaky tests as well.

We fix that, as well as clean up the for loop
a bit and mention how many messages were recieved
in the failure message so that it becomes clear
whether no messages were recieved, or atleast some
were received.

https://mattermost.atlassian.net/browse/MM-62079
```release-note
NONE
```
2025-01-08 20:03:59 +05:30
Agniva De Sarker
148dff2c24
MM-62378: Initialize status and session cache before loading license (#29686)
* MM-62378: Initialize status and session cache before loading license

ps.LoadLicense could end up calling InvalidateAllCaches. Therefore,
we need to intialize those caches before calling LoadLicense
to prevent a panic from happening.

While here, we also remove some unused code.

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

* fix lint errors

```release-note
NONE
```

* fix test

```release-note
NONE
```
2025-01-03 10:25:35 +05:30
Jesse Hallam
06a8c728c4
Fix cases where args... was not spread (#29668) 2024-12-23 11:22:02 -04:00
Yahya Haq
0482b57bf8
[MM-29441] Fix errcheck issues in web_hub.go (#29614)
* fix errcheck for web_hub.go

* log user id
2024-12-23 15:09:50 +05:30
Doug Lauder
3b125a4564
Fix bug in SqlPostStore.PermanentDeletebyUser where no error was returned when 10K posts was exceeded. Remaining posts were silently orphaned. (#29642)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-12-20 16:32:16 -05:00
Jesse Hallam
9e01424b15
Improve system admin permissions to dms and gms (#29656)
* revert the api4 portion of 57372bd06b

* test: Add system admin channel access tests

* skip a.HasPermissionToTeam for channels without a team

* fix TestPostGetInfo
2024-12-20 12:49:58 -04:00
TheInvincible
812034f5eb
Update export.go (fix errcheck issue) (#28971) 2024-12-20 17:45:13 +01:00
Ibrahim Serdar Acikgoz
902888efd9
server/channels/app/export_test: fix a lint error due to err check (#29650) 2024-12-19 19:34:46 +01:00
Ibrahim Serdar Acikgoz
e76786278b
[MM-60083] export: do not export DMs/GMs if users are deleted (#28854) 2024-12-19 16:47:52 +01:00
Seiya Homma
cf392f7cca
[MM-62143] Avoid SELECT * in role_store.go 2024-12-19 13:57:10 +01:00
Ibrahim Serdar Acikgoz
bf4d41954a
[MM-53245] export/import: add Props to the replies (#29531) 2024-12-18 17:36:17 +01:00
Harshil Sharma
041c874961
Reduced unnecessary debug logs from scheduled post job (#29560)
* Reduced unnecessery debug logs from scheduled post job

* Improved log
2024-12-18 12:58:32 +05:30
Ivy Gesare
0e4e7ca0b9
[MM-61514] Fix errcheck issues in server/channels/app/web_broadcast_hooks_test.go (#29213)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2024-12-17 15:09:24 -06:00
Ibrahim Serdar Acikgoz
bdbce2f8be
server/channels/app/import_functions_test: fix build errors (#29630) 2024-12-17 10:36:58 -05:00
Arya Khochare
cf93d2a14e
Fixed errcheck issues in server/channels/app/export_test.go (#29004)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-12-17 16:15:38 +01:00
Scott Bishel
faa7e4f2ea
MM-62188 - Revoke user sessions when converted to bot (#29573)
* revoke user sessions when converted to bot

* lint fixes
2024-12-17 07:55:10 -07:00
Ibrahim Serdar Acikgoz
de59770797
[MM-51468] import: allow usernames to be uppercase (#29530) 2024-12-17 13:27:53 +00:00
Ibrahim Serdar Acikgoz
74afa1fa78
[MM-60684] GetMaxPostSize: update threshold to V2, it was way overdue (#28662) 2024-12-17 13:26:48 +00:00
Arya Khochare
1f7f0d20cd
Fixed errcheck issues in server/channels/app/migrations.go (#29067) 2024-12-17 14:16:37 +01:00
Arya Khochare
cdfadcf47d
Fixed errcheck issues in server/channels/app/security_update_check.go (#29200) 2024-12-17 12:52:43 +01:00
Ibrahim Serdar Acikgoz
b59819da68
[MM-56986] imports/import_validators: add valid guest role check (#28658) 2024-12-17 11:49:55 +00:00
Ibrahim Serdar Acikgoz
424ce2b8db
[MM-59503] export: enable exporting configuration with mmctl (#28412) 2024-12-17 10:23:52 +01:00
fume4mattermost
4a5994906c
[MM-56031] Add DeleteSidebarCategory method and channel category API tests (#29161)
* Add DeleteSidebarCategory method and channel category API tests

* Add test to verify channels move to default categories when custom category is deleted

* rename channel category tests and remove duplicate context

* TestNotifications fix

---------

Co-authored-by: Fume <contact@fumedev.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-12-16 16:29:43 -05:00
Jesús Espino
d316df6d28
Replacing interface{} with any everywhere (except generated mocks) (#29446) 2024-12-15 21:11:36 +01:00
Seiya Homma
01415bee9c
Resolve backward compatibility issues (#29566)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-12-13 12:49:00 -04:00
Agniva De Sarker
bc22267829
MM-61699: Improve TestDeletePostEvent (#29575)
This test failed because TestWebHubCloseConnOnDBFail failed
and therefore the ChannelMembers table failed to be
renamed back.

We can see that in the logs:

```
teams","request_id":"sdxjxsd1wibd9mb7kc3ixj6g1w","ip_addr":"127.0.0.1","user_id":"afw9qqjh7pnddqakraxnjf1oph","method":"POST","user_id":"afw9qqjh7pnddqakraxnjf1oph","team_id":"bocubwmn4jyrmc1p9uxrc4pwfc","error":"JoinDefaultChannels: Unable to save direct channel., channel_members_save: Error 1146 (42S02): Table 'dbrt3jzcosj3nb8g6mgwmqyss9rh.ChannelMembers' doesn't exist"}
{"timestamp":"2024-11-10 13:52:34.260 Z","level":"error","msg":"Error while invalidating channel member cache","caller":"platform/web_hub.go:524","user_id":"afw9qqjh7pnddqakraxnjf1oph","error":"failed to find ChannelMembers, TeamScheme and ChannelScheme data: Error 1146 (42S02): Table 'dbrt3jzcosj3nb8g6mgwmqyss9rh.ChannelMembers' doesn't exist"}
{"timestamp":"2024-11-10 13:52:34.260 Z","level":"error","msg":"Error while invalidating channel member cache","caller":"platform/web_hub.go:524","user_id":"afw9qqjh7pnddqakraxnjf1oph","error":"failed to find ChannelMembers, TeamScheme and ChannelScheme data: Error 1146 (42S02): Table 'dbrt3jzcosj3nb8g6mgwmqyss9rh.ChannelMembers' doesn't exist"}
```

There is nothing wrong with this test. And while
we are here, we slightly improve the for-select loop
to exit faster.

https://mattermost.atlassian.net/browse/MM-61699
```release-note
NONE
```
2024-12-13 13:28:58 +05:30
Jesús Espino
31351a48b0
Depublishing some app layer methods (#29559)
* Depublishing some app layer methods

* Fixing errors

* Addressing PR review comment

* Using goimports formatting now
2024-12-12 20:15:38 +01:00
Rohan Sharma
a5a92d825a
[MM-61102] Fix errcheck issues in server/channels/app/channel_bookmark_test.go (#28789)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-12-12 16:48:48 +01:00
Devin Binnie
3eb95af974
[MM-62086] Don't include deleted DMs/GMs when returning archived channels (#29572) 2024-12-12 15:19:21 +00:00
Devin Binnie
57372bd06b
[MM-62092] Allow system admins to pull posts in from DMs they're not in (#29557) 2024-12-12 15:12:21 +00:00
Agniva De Sarker
d20dbc3b88
MM-61698: Fix TestWebHubCloseConnOnDBFail properly (#29577)
Finally I figured out why the log message for
/api/v4/websocket does not appear. It is because
the log gets generated only when the request returns,
and for websockets, the request doesn't return
until the client closes. And because we were closing
the client in a defer clause, the flushing of the logger
would happen before closing the client, therefore
leading to a race condition of the log not appearing
from time to time.

https://mattermost.atlassian.net/browse/MM-61698
```release-note
NONE
```
2024-12-12 18:55:44 +05:30
Ivy Gesare
832b5a3332
[MM-61771] Fix errcheck issues in server/channels/app/platform/service_test.go (#29375)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-12-12 13:51:16 +01:00
Seiya Homma
55500b573a
[MM-61776] Fix errcheck issues in server/channels/app/platform/web_conn.go (#29515) 2024-12-12 12:19:23 +01:00
Kyrillos Isaac
267c4133b7
[MM-61263] fix: errcheck issues in server/channels/app/job_test.go (#29070)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-12-12 12:17:40 +01:00
AulakhHarsh
1b164c8302
Fix errcheck issues in server/channels/app/platform/service.go (#29366) 2024-12-12 11:22:57 +01:00
Agniva De Sarker
f3309633b2
MM-61698: Unskip TestWebHubCloseConnOnDBFail (#29546)
https://github.com/mattermost/mattermost/pull/29214 fixed the
race condition in web_hub initialization.

The failure in the test is strange because there's no log
for the websocket request. It's as if th.CreateWebSocketClientWithClient()
never got called at all.

I am re-arranging the lines so that even if it fails,
the table rename happens anyways. But overall, I don't see
any reason for the failure.

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

```release-note
NONE
```
2024-12-12 10:53:31 +05:30
Agniva De Sarker
bfdf6638ee
Adding error context in license validation (#29554)
While investigating https://mattermost.atlassian.net/browse/MM-61529,
I noticed that we weren't adding the internal error which made
it impossible to understand what was really happening.

```release-note
NONE
```
2024-12-12 10:33:46 +05:30
Felipe Martin
0ad5b6ac37
tests: skip flaky outgoing oauth connection tests (#29542) 2024-12-11 16:12:53 +01:00
Agniva De Sarker
7df4727353
[Aider assisted]: Use SelectBuilder and GetBuilder in webhook_store.go (#29555)
I was planning to kick off a campaign for this. But aider can do this just fine.

Starting off with a single file for now. But will slowly send more PRs with larger
commit diffs.

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-12-11 12:03:03 +05:30
Alejandro García Montoro
a906e980f9
Skip flaky test - Tracked in MM-62079 (#29494) 2024-12-10 15:46:59 +01:00
Jesse Hallam
5369f8b36b
s/Get(Master|Replica)X/Get\1/g (#29520)
Drop the legacy `X` suffix from `GetMasterX` and `GetReplicaX`. The
presence of the suffix suggests there's a `non-X` version: but in fact
we migrated these away a long time ago, so remove the cognitive
overhead.

As an aside, this additionally helps avoid trip up LLMs that interpret
this as "something to fix".
2024-12-10 09:57:19 -04:00
David Krauser
f1d5884532
MM-62105 use WARN log level when ws can't report hostname (#29523) 2024-12-10 09:33:44 +01:00
Agniva De Sarker
0f5d160131
MM-62077: Fix cluster broadcast for LRU caches (#29488)
We were incorrectly not broadcasting status cache updates
inspite of that being an LRU cache.

We were also not doing it for profilesInChannel cache.
Now we fix it by properly checking the invalidationEvent
which is something local to the cache itself rather
than the cache provider.

https://mattermost.atlassian.net/browse/MM-62077
```release-note
NONE
```
2024-12-10 11:08:17 +05:30
David Krauser
3224e0d3a2
MM-61991 Show server hostname in about modal (#29413)
This introduces a new entry in the `Main Menu -> About` modal with the hostname of the currently connected websocket. This will be used to aid debugging issues in clustered environments by showing which node in the cluster is servicing requests for a particular websocket.

This information is only visible in self-managed instances. It will not be visible on cloud instances.
2024-12-06 10:39:36 -05:00
fxnm
491e46d390
[MM-61477] Fixed exif rotates images width and height is not correctly calculated (#29309)
* [MM-61477] Fixed exif rotates images width and height is not correctly calculated

* [MM-61477] Apply rotation ony to png or jepg

* [MM-61477] Added test cases to verify correct rotation

* fix: fixed wrong format

* uff

* fix: exif rotation is only possible on jpeg images

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-12-05 13:16:01 -05:00
Alejandro García Montoro
6b648199f0
MM-61992: Verify license.Features.Users is not nil (#29417)
* Verify license.Features.Users is not nil

* Move check before DB call to avoid it if possible

* Add more context to the error
2024-12-05 16:46:04 +01:00
Jessie Kahn
82c1f7bf09
[MM-61508] Fixed errcheck issues in upload_test.go, [MM-61510] Fixed errcheck issues in user_test.go (#29308) 2024-12-05 12:22:41 +01:00
Agniva De Sarker
a6d37fa14c
MM-61887: Log the userID if a metric exceeds the last histogram bucket (#29448)
We create a custom histogram metric that logs the userID
when the observed value is greater or equal to the last bucket value.

This allows us to start tracking the slowest users of a system
while at the same time not polluting the Prometheus metrics
by storing a userID for every observation.

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

```release-note
NONE
```
2024-12-05 09:12:54 +05:30
k srisri reddy
961fc6bfe9
fix: MM-61260: handled errors to fix linting (#29340)
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2024-11-29 15:27:15 +00:00
Ivy Gesare
ff1ffc51dc
[MM-61460] Fix errcheck issues in server/channels/app/plugin_signature_test.go (#29348)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-29 10:36:19 +01:00
Agniva De Sarker
4ec4b4d525
MM-61886: Add actionable page navigation metrics (#29332)
Page load is one of the metrics that we track and present
to MLT. However, in its current form, it is not very
actionable because it also contains the network latency.

We split the whole metric into these parts:
startTime
|
responseStart = TTFB
|
responseEnd = TTLB
|
domInteractive = Start of processing phase
|
loadEventEnd = Load complete

This gives us better visibility into exactly
which phase in the load process is slow.

I have experimented with other metrics like
- domContentLoadedEventStart
- domContentLoadedEventEnd
- domComplete

and observed that they do not have sufficient
gaps in the timespan to have any relevance.

Additionally, I have moved TTFB from being a
web vitals metric to being tracked from the performance
metrics to remain consistent with the other navigation
metrics measured.

Lastly, I took this chance to improve some of the
validation errors that we threw to include more
context into the input that was passed and why
does it fail.

This also meant that I had to change the tests
to check for error strings rather than direct
errors which is a bad thing, but I don't think
it's worth the effort trying to have named error
variables for all of them.

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

```release-note
NONE
```
2024-11-29 11:24:35 +05:30
AulakhHarsh
2c32040e2e
[MM-61769] Fix errcheck for /platform/searchengine.go (#29341)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-28 10:17:33 +01:00
Arya Khochare
54eff271bd
Fixed errcheck issues in server/channels/app/integration_action_test.go (#29039)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-27 14:02:12 +01:00
AulakhHarsh
d9981beb9d
Fix errcheck issues in server/channels/jobs/resend_invitation_email/worker.go (#29353)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-27 12:07:31 +01:00
Pablo Vélez
48c14af280
MM-61297 - remove unused code (#29354)
* MM-61297 - remove unused code

* remove unused code for install plugin in backend

* fix translations
2024-11-26 19:11:21 -05:00
AulakhHarsh
edbcb247c6
Fix errcheck issues in server/channels/app/platform/log.go (#29349)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-26 16:22:31 +01:00
Ivy Gesare
193f9463ed
Change: Fix errcheck issues in server/channels/app/platform/session_test.go (#29376) 2024-11-26 10:15:13 +08:00
AulakhHarsh
f4e9221261
[MM-61768] Fix #29337 Errcheck in channels/app/platform/metrics.go (#29347) 2024-11-25 13:44:36 +01:00
Ivy Gesare
a61ffadd84
[MM-61766] Fix errcheck issues in server/channels/app/platform/link_cache.go (#29363) 2024-11-25 13:41:16 +01:00
TheInvincible
8e2610e459
update status_test.go (fix errcheck issue) (#29157)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-22 15:10:23 +01:00
Seiya Homma
5234b6897e
[MM-61761] Fix errcheck issues in channels/app/platform/cluster_handlers.go (#29302)
* Fixed errcheck issues

* fixed issues

* fixed issues

* Fix merge conflict

* fix code
2024-11-22 12:40:26 +05:30
Julien Tant
3b1eb64e02
[MM-51201/MM-60406/MM-60404] CrossTeam Search posts and files (#28478)
* poc - wip

* add search files across teams

* eslint

* fix existing tests

* fix webapp style

* fix test

* add api doc

* change initial state in test

* add tests on API

* add tests on file info layer

* fix file search tags

* add rhs reducer test

* reset team selected when the RHS is suppressed

* change css to reflect UI

* fix style

* fix doc wording

* make getSearchTeam return currentTeamId when value is not set

* await is unnecessary

* revert boolean check and add test

* add comment to getSearchTeam to let dev knows it defaults to currentTeam

* remove redundant team check

* simplfy test

* fix style check

---------

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-21 13:40:46 -07:00
David Edler
d59c5b2608
Fixed errcheck issues in server/channels/app/import_functions_test.go (#29229) 2024-11-21 13:14:07 +01:00
Arya Khochare
45860309b1
Fixed errcheck issues in server/channels/app/plugin_install.go (#29062)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-21 11:30:30 +01:00
Ben Schumacher
5911590ce6
[MM-61858] Fix flaky TestSendNotifications (#29339) 2024-11-21 09:51:59 +01:00
Vishal
746eb70e01
[MM-60689] Add Webhook ID in the logs (#28846)
* add webhook id to logs

* Move hook_id context to api level from app level.

* pass errCtx to other references of same app-error-id

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-21 13:53:10 +05:30
Scott Bishel
790103fae0
MM-59540 Ensure user has invite team permission in order to change setting (#28670)
* ensure user has invite team permission in order to change setting

* add tests and handle UI

* lint fixes

* revert changes to invite section input

* update tests

* revert bad merge

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-20 16:02:32 -07:00
Ben Schumacher
11b66de686
[MM-61693] Only check for LDAP info if LDAP is enabled during Support Packet generation (#29185) 2024-11-20 17:55:37 +01:00
Arya Khochare
b986f39825
Fixed errcheck issues in server/channels/api4/user_test.go (#28647)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-20 17:28:39 +01:00
TheoForger
4bb4f9814b
[MM-61077] Fix errcheck issues in server/channels/web/static.go (#29285)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-20 14:44:22 +01:00
Rohan Sharma
5de425c298
[MM-61462] Fix errcheck issues in server/channels/app/post.go (#29205)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-20 14:43:48 +01:00
Ivy Gesare
82bd3b6df1
[MM-61762] Fix errcheck issues in server/channels/app/platform/config_test.go (#29323)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-20 12:23:44 +01:00
molejnik88
1a095f74c2
[MM-61459] Fix errcheck issues in server/channels/app/plugin_signatur… (#29202) 2024-11-20 10:40:05 +01:00
Agniva De Sarker
5c5276312b
Fix race condition in app/channel_test.go (#29331) 2024-11-20 10:28:02 +01:00
Arya Khochare
ed7a38e80c
Fixed errcheck issues in server/channels/app/server_test.go (#29199)
* errcheck issues fixed

* NoError to Error

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-19 12:45:47 -05:00
Domenico Rizzo
f64402e5c5
MM-61519 Fix errcheck in channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go (#29284)
* Removed test_update_user_auth_plugin from golangci

The test_update_user_auth_plugin has been removed from the .golangci.yml configuration file. This change simplifies the linting process by excluding unnecessary files.

* Refactored error handling in user auth tests

The error handling for the 'expectUserAuth' function within the user authentication plugin tests has been refactored. Previously, errors were not being explicitly checked after each call to this function. Now, an error check is performed after each invocation and if an error is found, it's immediately returned. This change improves the robustness of our test suite by ensuring that potential issues are caught and handled appropriately during testing.

* Refactor error handling in UpdateUserAuth

The error handling in the UpdateUserAuth function has been refactored. The variable 'err' was replaced with 'appErr' to better reflect its purpose and improve code readability.

* Updated user authentication in plugin API

The user authentication method in the plugin API has been updated. Previously, it was fetching the user based on a static configuration value. Now, it fetches the user dynamically using the provided userID. This change makes the function more flexible and adaptable to different use cases.

* Updated golangci configuration

Removed a test file from the exclusion list in the golangci.yml configuration. This will allow linting checks to be performed on this previously excluded file, improving code quality and consistency.

* Updated golangci configuration

Removed a test file from the exclusion list in the golangci configuration. This will ensure that our linting tools also cover this previously excluded test file, improving overall code quality checks.

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-19 11:54:58 -05:00
Nick Misasi
8f716a61e6
remove Stripe CSP from server (#29306)
* remove Stripe CSP from server

* Update tests

* Fix more tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-19 10:57:32 -05:00
Harshil Sharma
05abb39019
Revert ana ccidental change (#29325) 2024-11-19 17:50:37 +05:30
David Edler
03a4462b19
Fixed errcheck issues in server/channels/app/channel_test.go (#29233)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-19 12:46:27 +01:00
Harshil Sharma
949e13725f
Added precense check for scheduled posts before accessing error code (#29322)
* Added precense check for scheduled posts before accesing error code

* Expliocitelly stated the undefined nature
2024-11-19 10:58:09 +00:00
AulakhHarsh
e5a4b1efba
Fix errcheck issues in server/channels/app/platform/busy_test.go (#29318) 2024-11-19 10:45:54 +01:00
Agniva De Sarker
c6a7a8f628
Fix flaky TestCreatePost and others (#29320)
We don't clear the Redis cache for every test.
This can cause issues because the cache is shared
across test. We fix that with this PR.
```release-note
NONE
```
2024-11-19 14:23:37 +05:30
Rohan Sharma
aa0d117f30
[MM-61101] Fix errcheck issues in server/channels/app/channel.go (#28787)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-19 08:56:23 +01:00
Agniva De Sarker
7f032b0b39
MM-61524: Fix flaky test RedisPubSub (#29311)
- We refactor some of the testlib assertion code
and add a new function to just return true or false.

https://mattermost.atlassian.net/browse/MM-61524
```release-note
NONE
```
2024-11-18 14:55:34 +05:30
TheInvincible
c2c2bc1efe
update status.go (fix errcheck issue) (#29156)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-18 09:23:11 +01:00
Rohan Sharma
c682f649b5
[MM-61464] Fix errcheck issues in server/channels/app/post_metadata.go (#29204)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-18 08:35:50 +01:00
Agniva De Sarker
d6a89c69c2
Fix flaky test TestScheduledPostStore (#29301)
There were couple of errors in the test:
1. UpdatedScheduledPost will automatically
set the ProcessedAt to now internally inside
toUpdateMap. So setting the value from outside
has no effect.
2. The bug was that if it took more than a
milisecond to capture the time, and then
do the internal call, then the Get call
will have a higher value and therefore fail.

Since UpdatedScheduledPost doesn't return
an updated post, so there is no need
to compare the timestamps at all.
```release-note
NONE
```
2024-11-16 14:32:46 +05:30
pRAnaY
504934b612
fixed errcheck in test_serve_metrics_plugin (#29289) 2024-11-15 21:02:17 +01:00
Harrison Healey
207503185e
MM-61012 Add special handling to OS detection for mobile apps (#29139)
* Stop recording unknown platforms as "Windows" in Sessions table

* Add more tests to user_agent_test.go

* MM-61012 Add special handling to OS detection for mobile apps

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-15 12:25:28 -05:00
Rohan Sharma
8aac1a0e2b
[MM-61466] Fix errcheck issues in server/channels/app/post_persistent_notification_test.go (#29207) 2024-11-15 13:55:11 +01:00
Harshil Sharma
04b68c5cce
Fix flaky TestHandleFailedScheduledPosts test (#29292)
* Simplified test

* Restored original timeout duration
2024-11-15 11:45:28 +00:00
Domendra Singh Komra
ee1d6eb887
Fixes errcheck issues in server/channels/api4/team_test.go (#29151)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-15 12:17:38 +01:00
Ivy Gesare
9b15c50418
[MM-61509] Fix errcheck issues in server/channels/app/user.go (#29154)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-15 11:13:15 +01:00
Agniva De Sarker
d83156027a
Fix race condition in the web package (#29288)
Essentially applying the fix for https://github.com/mattermost/mattermost/pull/29214
to the web package. It seems like the app.StoreOverrideWithCache
function was never used in this package.

Just a small highlight of how much boilerplate is repeated
in multiple packages
```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-15 11:30:56 +02:00
Ibrahim Serdar Acikgoz
0e6ec05d5c
[MM-53339] import: dont miss out reactions from replies (#29060) 2024-11-15 09:45:14 +01:00
mas-who
3da77f2f05
GH-29265: Fix errcheck errors in server/channels/app/platform/feature_flags.go (#29269)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-15 09:32:11 +01:00
Agniva De Sarker
8d1c42bc91
MM-61229: Place Redis behind enterprise (#28917)
And re-order the server initialization (AGAIN).

For the nth time, we found several bugs in the initialization
process.

1. filestore.NewExportFileBackend and filestore.NewFileBackend
depended on license, but the license wasn't even loaded until
later!
2. The `ps.sqlStore.UpdateLicense` call also didn't work
because the license wouldn't get loaded. It only accidentally
worked because of `ps.AddLicenseListener` which would update
the license later on. We remove that.

Ideally, we would have loaded the license first and then
checked for redis client, but it's very difficult to do that.
Reasons are explained in the code comment.

So we just wait until the license is loaded, and simply throw an
error later.

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

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-15 13:27:23 +05:30
yasserfaraazkhan
38823603a3
E2E test for scheduled Draft feature (#28433) 2024-11-15 02:39:35 +05:30
pRAnaY
7403d29634
[MM-61517] Fix errcheck issues in channels/app/plugin_api_tests/manual.test_http_hijack_plugin (#29190)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-14 13:47:19 -06:00
Ben Schumacher
4620ab6ad3
Skip flaky TestWebHubCloseConnOnDBFail (#29268) 2024-11-14 22:31:34 +05:30
Pablo Vélez
fb0582c04e
MM-61731 - enhance failed sent system bot message (#29253)
* MM-61731-enhance-failed-sent-system-bot-message

* adjust test and adjust i18n messages

* set back correct value

* improve naming and get channels logic

* hide channel name if the channel is private

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-14 16:56:40 +01:00
mas-who
f48fd7b791
GH-28752 fix errcheck lint issues in server/channels/testlib/helper.go (#29260) 2024-11-14 13:13:45 +01:00
Ben Schumacher
18c5fe8f6a
Skip flaky TestEditChannelBookmark/a_websockets_event_should_be_fired_as_part_of_editing_a_bookmark (#29267) 2024-11-14 10:19:52 +00:00
Seiya Homma
6e81e8c35c
[MM-61512] Fix errcheck issues in server/channels/app/users/helper_test.go (#29167)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-14 10:19:52 +01:00
Elias Nahum
701d1dbd68
optionally exclude threads in direct messages (#29042)
* optionally exclude threads in direct messages

* add excludeDirect option in client4

* Skip flaky test

* refactor double negate

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-14 16:57:15 +08:00
Arya Khochare
38e2f67583
Fixed errcheck issues in server/channels/app/slashcommands/command_loadtest.go (#29169)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-14 09:51:53 +01:00
TheInvincible
45235a0ef6
Update file_info.go (fix errcheck issue) (#28966)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-14 08:42:32 +01:00
Sumedha Koranga
e7e1d7d7ce
[MM-61513] Fix errcheck issues in channels/app/users/users_test.go fixes #29179 (#29188)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-14 08:34:41 +01:00
Alexandre Sollier
3ed337b34d
[MM-61511] Fix errcheck issues in channels/app/user_viewmembers_test.go (#29149) 2024-11-14 08:31:00 +01:00
Elias Nahum
83c3d4385a
MM-60481/MM-61301 fix bookmarks flaky tests (#29141)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-14 12:34:10 +08:00
Agniva De Sarker
63c959f1d3
Fail fast while connecting to replicas (#29212)
Since we have the auto-retry mechanism for replicas,
there is not much benefit in trying 5 times before deciding
to move on.

In the earlier model, we would fail the server startup,
so it made sense to check as many times as possible.

Also reducing the sleep interval so that we can improve
the boot up time in case of a bad replica.
```release-note
NONE
```

* fix: Add job name to the publish report step

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com>
2024-11-14 09:45:52 +05:30
Arya Khochare
94036947c8
Fixed errcheck issues in server/channels/app/session_test.go (#29198) 2024-11-13 20:32:25 +01:00
TheInvincible
11edef7af0
update command_remove_test.go (fix errcheck issue) (#29177)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-13 20:21:49 +01:00
Alenoda
891b2144df
Fix errcheck issues in server/channels/app/login_test (#29119)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-13 20:08:23 +01:00
Arya Khochare
a19ec14967
Fixed errcheck issues in server/channels/app/product_notices_test.go (#29194) 2024-11-13 20:04:22 +01:00
Harshil Sharma
80f69a9c84
Skipping flaky TestClientGetOutgoingOAuthConnection test (#29178) 2024-11-13 12:02:53 +00:00
Ben Schumacher
053d0b5f0a
[MM-61140] Allow plugins to add Support Packet data without UI elements (#28833)
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2024-11-13 11:20:39 +01:00
Harshil Sharma
c79a8a8b4a
MM-61484 - Deleting scheduled posts when permanently deleting a user (#29152)
* Deleting scheduled posts when permanently deleting a user

* Updated tests

* CI

* Testing CI

* Restored a test change

* Skipping flaky test
2024-11-13 12:41:31 +05:30
Ben Schumacher
8c3f4a5818
Fix broken TestGetPost (#29228)
* Fix broken TestGetPost

* Skip TestPromoteGuestToUser/websocket_update_user_event

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-13 10:13:12 +05:30
Ivy Gesare
4a92e9f9bf
[MM-61516] Fix errcheck issues in server/channels/app/plugin_api_test.go (#29220) 2024-11-12 15:56:35 -05:00
Rohan Sharma
73f1383f5f
[MM-61465] Fix errcheck issues in server/channels/app/post_metadata_test.go (#29206) 2024-11-12 15:54:51 -05:00
Pablo Vélez
4e0fc5734c
MM - 60506 - notify user failed scheduled msgs (#29208)
* MM-60506 - notify user for failed scheduled messages

* add unit tests for handleFailedScheduledMessages and send system-bot message

* fix vet issues

* adjust test for vet report

* make sure to send the message to every user there was a failed message

---------

Co-authored-by: Harshil Sharma <harshil.sharma@mattermost.com>
2024-11-12 11:33:29 +01:00
Arya Khochare
5eef415a39
Fixed errcheck issues in server/channels/api4/post_test.go (#29201) 2024-11-12 10:07:19 +01:00
Harshil Sharma
7c3d71c089
Scheudled post test enhancement (#29187)
* Added test for user beloonging to channel but not team

* Added test for read onmly channel

* Added test for fetching scheduled posts for team you don;'t belong to

* Added more tests

* test enhancements

* CI
2024-11-12 12:29:29 +05:30
Harshil Sharma
56260e93d4
Added debug settings for testing and e2e tests (#29175) 2024-11-12 11:26:14 +05:30
Agniva De Sarker
847f42fd4c
MM-61700: Fix race conditions from web_hub initialization (#29214)
The Store variable was written to _after_ the server
started which was causing the race.

We simply move it to before we start the server.

While we are here, we fix yet another race condition
which was unrelated, but doing it in one sweep. This
was related to the user props access. When a user is updated,
there was 3 ws events that get sent out, 2 were deep-copied
whereas 1 was not. This led to race condition in postgres
binary-param mode where we were trying to set the user props.



https://mattermost.atlassian.net/browse/MM-61700
2024-11-12 08:46:18 +05:30
Arya Khochare
2461d0fed6
errcheck issues fixed (#29196) 2024-11-11 16:55:10 +01:00
Arya Khochare
ead2a7c018
Fixed errcheck issues in server/channels/app/imaging/decode.go (#28937) 2024-11-08 15:39:03 +01:00
Daniel Espino García
118d0346ee
Add test notification tool (#28334)
* Add test notification tool

* Add frontend styles

* Remove option from admin view

* Refactor create post and add translations

* Fix several CI errors

* Fix API and frontend snapshots

* Refactor trailing and leading icon on buttons

* Add different button states

* i18n-extract

* Fix wrong text

* Add tests

* Fix wrong string

* Fix test

* feat: E2E send test notifications (#28371)

* Refactor send desktop notification

* Address rest of the feedback

* Fix tests

* Add correct link

* Fix test

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
2024-11-08 13:57:06 +01:00
Pablo Vélez
2593860063
MM-61068 - send ws event on scheduled message job send (#29153)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-08 10:48:23 +01:00
Niharika Goulikar
f377399c4c
Fixed errcheck isssues in Auto_responder_test.go (#28987)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-08 08:54:03 +01:00
Agniva De Sarker
bd8774bdce
MM-61130: Use a channelMember map at web_hub level (#28810)
Tests at very high scale indicates that the iteration
of all connections during websocket broadcast starts
to become a bottleneck.

To optimize this, we move the channelMember cache from
inside web_conn.go to the hubConnectionIndex.

This involves adding a new map keyed by the channelID
and containing all webConns where the user is a member
of that channel. Subsequently, a new method needed to
be added to invalidate the cache which previously
used to happen in web_conn.

And as a last step, we remove the cache from web_conn
to reduce SQL queries to the DB.

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

```release-note
NONE
```
2024-11-08 09:57:54 +05:30
Nicolas Le Cam
c90e562528
Migrate mockery to packages feature (#29013) 2024-11-07 12:48:11 +01:00
Nicolas Le Cam
5ebdea506f
MM-39918: mmctl: list archived private channels in channel list command with system admin user (#28676) 2024-11-07 12:07:30 +01:00
Ivy Gesare
7846ac86b4
[MM-61506] Fix errcheck issues in server/channels/app/teams/helper_test.go (#29144) 2024-11-07 10:11:55 +01:00
Nils
d8f70551bd
[GH-28399] Errcheck jobtest (#28689)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-07 09:37:07 +01:00
molejnik88
e40d7b442a
[MM-61458] Fix errcheck issues in server/channels/app/plugin_requests.go (#29121) 2024-11-07 09:09:11 +01:00
Arya Khochare
efa93a3dd3
Fixed errcheck issues in server/channels/app/onboarding_test.go (#29066) 2024-11-06 11:50:21 +01:00
Harshil Sharma
f812104a92
MM-60331 - Scheduled post telemetry (#29132)
* Added scheduled posts telemetry

* Tracking scheudled post creation via webapp to filter by platform

* Fixed keys

* Lint fix
2024-11-06 10:39:52 +00:00
Arya Khochare
4d4af7dc39
errcheck issues fixed (#29061)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-06 00:55:33 +01:00
Alenoda
74b33c73fb
Fix errcheck issues in server/channels/app/plugin_deadlock_test.go (#29113)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-05 19:17:56 +01:00
Rohan Sharma
6b5732a6af
[MM-61100] Fix errcheck issues in server/channels/app/busy_test.go (#28786) 2024-11-05 19:17:22 +01:00
Guillermo Vayá
751d84bf13
[MM-59363] Shared channel event telemetry (#29024)
* shared channel event tracking

* Update notification.go

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>

---------

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
2024-11-05 16:26:18 +01:00
Arya Khochare
373e21c5a1
Fixed errcheck issues in server/channels/app/plugin_hooks_test.go (#29059) 2024-11-05 15:36:19 +01:00
Pablo Vélez
fbee99e870
MM-60124-emit and read create scheduled post WS event (#28844)
* MM-60124-emit and read create scheduled post WS event

* fix unit test; reorder get team id logic; use userid for ws events

* MM-60145 - ws events on update scheduled posts (#28871)

* MM-60145 - ws events on update scheduled posts

* MM-60147 - ws events on delete scheduled posts (#28872)

* MM-60147 - ws events on delete scheduled posts

* remove unnecessary channelID

* remove unnecesary memoization
2024-11-05 14:24:50 +01:00
Ivy Gesare
cb8f152089
[MM-61094] Fix errcheck issues in server/channels/app/app_test.go (#29124) 2024-11-05 12:13:41 +01:00
Alenoda
4b9eb73bd2
Fix errcheck issues in server/channels/app/plugin_reattach (#29115)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-05 09:59:24 +01:00
Ivy Gesare
795b2ad068
[MM-61488] Fix errcheck issues in server/channels/app/role_test.go (#29125) 2024-11-05 09:58:54 +01:00
Arya Khochare
9ecf9f8ade
Fixed errcheck issues in server/channels/app/notification_test.go (#29068) 2024-11-05 08:59:48 +01:00
Arya Khochare
6fd464a398
errcheck issues fixed (#29045) 2024-11-04 17:38:09 +01:00
Ben Schumacher
63bf746d60
[MM-61523] Skip flaky TestGetUserTeamScheduledPosts/should_get_created_scheduled_posts (#29104) 2024-11-04 14:45:22 +01:00
Arya Khochare
ef1be57f64
errcheck issues fixed (#29063)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-04 14:33:47 +01:00
Arya Khochare
e3f6b16927
errcheck issues fixed (#29065) 2024-11-04 07:49:02 -05:00
Kyrillos Isaac
3780887629
[MM-61106] fix server/channels/app/desktop_login.go errcheck issues (#28818)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-04 13:27:07 +01:00
Arya Khochare
dc5640f134
Fixed errcheck issues in server/channels/api4/file_test.go (#28559) 2024-11-04 13:26:03 +01:00
Dishika Vaishkiyar
19865329ca
Fix: authorization-test errcheck issue (#28788)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-04 13:04:06 +01:00
Ivy Gesare
89ea59f590
[MM-61259] Fix errcheck issues in server/channels/app/import_utils_test.go (#28955) 2024-11-04 12:33:53 +01:00
Pratham Mahajan
cb32e8baea
Fix errcheck issues in server/channels/jobs/schedulers_test.go (#28970) 2024-11-04 12:25:09 +01:00
Harshit Vashisht
59c42c06ef
Fixes errcheck in email_test.go (#28910)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-04 12:16:35 +01:00
Arya Khochare
a21e8f9b13
Fixed errcheck issues in server/channels/app/ldap.go (#29038) 2024-11-04 12:05:43 +01:00
Arya Khochare
93b0fece12
Fixed errcheck issues in server/channels/app/oauth_test.go (#29043) 2024-11-04 11:13:16 +01:00
Samarth Mishra
e86560d04c
Fix errcheck issues in server/channels/app/imaging/decode_test.go (#28958)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-04 10:55:48 +01:00
TheInvincible
fdd5bb9c02
Update file_helper_test.go (fix errcheck issue) (#28983) 2024-11-04 09:31:30 +01:00
TheInvincible
be7a8a17c0
Fix errcheck issue in oauth.go (#28795) 2024-11-04 09:07:04 +01:00
Rohan Sharma
f2182d806b
[MM-61097] Fix errcheck issues in server/channels/app/bot.go (#28785)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-11-04 08:56:59 +01:00
Harshil Sharma
e281b3f37e
Feature scheduled messages (#28932)
* Create scheduled post api (#27920)

* Added migration files for Postgres

* Added migrations for MySQL

* Added store method

* Added API and store tests

* Renamed migration after syncing with master

* Added app layer tests

* API is ready

* API is ready

* API is ready

* Renamed migration after syncing with master

* Updated migration list

* Fixed retry layer tests

* Allowed posts with empty messages

* Review fixes

* Reverted an incorrect change

* Renamed migration and fixed ID assignment

* CI

* Send post button changes (#28019)

* added Split button

* WIP

* Added core menu options

* WIP

* WIP

* WIP

* Handled displaying error in creating scheduled post

* lint fixes

* webapp i18n fix

* Review fixes

* Fixed a webapp test

* A few more fixes

* Removed a duplicate comment

* Scheduled post job (#28088)

* Added the job function

* Added query for fetching scheduled posts for pricessing

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Reafactoring of scheduled post job

* Lint fixes

* Updated i18n files

* FInishing touches

* Added tests for GetScheduledPosts

* Added tests for PermanentlyDeleteScheduledPosts

* Updated all layer

* Some changes as discussed with team

* Added tests for UpdatedScheduledPost

* Code review refactoring

* Added job test

* MM-60120 - Custom time selection (#28120)

* Added a common date time picker modal and used it for post reminder

* Added a common date time picker modal and used it for post reminderggp

* Added modal for custom schedule time and fixed TZ issue

* WIP

* Removed event from useSubmit hook

* Removed event from useSubmit hook

* Added timezone handling

* fixed type error

* Updated i18n strings

* Minor cleanup

* updated snapshots

* review fixes

* Handled event

* Supported for having a DM thread open in RHS while in a regular channel

* Review fixes

* MM-60136 - Scheduled messages tab (#28133)

* WIP

* WIP

* Created Tabs and Tab wrapper with added styling

* Added API to get scheduled posts

* WIP

* Displated scheduled post count

* i18n fix

* Added tests

* Handled asetting active tab absed on URL:

* Reverted unintended change

* Added API to client ad OpenAPI specs

* Renamed file

* Adding fileinfo to schedule posts

* Partial review fixes

* Made get scheduled post API return posts by teamID

* review fixes

* Moved scheduled post redux code to MM-redux package

* Usedd selector factory

* WIP:

* WIP:

* Lint fix

* Fixed an incorrect openapi spec file

* Removed redundent permission check

* Clreaed scheduled post data on logout

* Removed unused i18n string:

* lint fix

* Render scheduled posts (#28208)

* WIP

* WIP

* Created Tabs and Tab wrapper with added styling

* Added API to get scheduled posts

* WIP

* Displated scheduled post count

* i18n fix

* Added tests

* Handled asetting active tab absed on URL:

* Reverted unintended change

* Added API to client ad OpenAPI specs

* Renamed file

* Created common component for draft list item

* WIP

* WIP

* Adding fileinfo to schedule posts

* Basic rendering

* Added count badge to tabs

* WIP

* Made the Drafts LHS iteam appear if no drafts exist but scheduled posts do

* Fixed icon size

* Partial review fixes

* Made get scheduled post API return posts by teamID

* Handled initial vs team switch load

* Displayed scheduled date in panel header

* Added error message and error indiocator

* WIP

* review fixes

* WIP Adding error reason tag

* Added error codes

* Moved scheduled post redux code to MM-redux package

* Usedd selector factory

* WIP:

* WIP:

* Lint fix

* Fixed an incorrect openapi spec file

* Removed redundent permission check

* Clreaed scheduled post data on logout

* Removed unused i18n string:

* lint fix

* Opened rescheduling modal

* Updated graphic for empty state of schduled post list

* Added delete scheduled post option and modal

* Badge and timezone fix

* WIP:

* Added send now confirmation modal

* lint

* Webapp i18n fix

* Fixed webapp test

* Fixed a bug where DM/GM scheduled posts weren't immideatly showing up in UI

* Minor fixes

* WIP

* Review fixes

* Review fixes

* Optimisations

* Fixed reducer name

* Moment optimizatin

* Updated route check

* MM-60144 - added API to update a scheduled post (#28248)

* WIP

* Added api and ap layer for update scheduled post ̛̦̄

* Added API to OpenAI specs, Go client and TS client

* removed permissio check

* Added tests

* Fixed tests

* Added PreUpdate method on scheduled post model

* MM-60131 - Reschedule post integration (#28281)

* Handled rescheduling post in webapp

* Added error handling

* MM-60146 - Delete scheduled post api (#28265)

* WIP

* Added api and ap layer for update scheduled post ̛̦̄

* Added API to OpenAI specs, Go client and TS client

* removed permissio check

* Added tests

* Fixed tests

* Added PreUpdate method on scheduled post model

* Added delete scheduled post API

* Added API to Go client and OpenAPI specs

* Added API to TS client

* Added tests

* CI

* Rmeoved two incorrect code comments

* MM-60653 - Integrated delete scheduled post API (#28296)

* Integrated delete scheduled apost API

* Lint fix

* Review fixes

* Excluded draft checks from scheduled posts (#28370)

* Excluded draft checks from scheduled posts

* Added a removed todo

* MM-60125 - Scheduled post channel indicator (#28320)

* Integrated delete scheduled apost API

* Lint fix

* Added state for storing scheduled posts by channel ID

* Refactored redux store to store scheudled posts by ID, thens tore IDs everywhere

* Refactored redux store to store scheudled posts by ID, thens tore IDs everywhere

* WIP

* Added scheduled post indiocator

* Handled single and multiple scheudled posts

* Review fixes

* Fixed styling and handled center channel, RHS and threads view

* Lint fix

* i18n fix

* Fixed a cycling dependency

* Lint fix

* Added some more comments

* Updated styling

* Review fixes

* Added common component for remote user time and scheduled post indicator

* Updated scheduled post count

* Minor change

* Moved CSS code around

* Fixed a bug where files in scheduled post didn't show up until refresh (#28359)

---------

Co-authored-by: Daniel Espino García <larkox@gmail.com>

* Scheduled post config (#28485)

* Added config

* Added config on server and webapp side

* Added config check in server and webapp

* Added license check

* Added license check

* Added placeholder help text

* Added license check to job

* Fixed job test

* Review fixes

* Updated English text

* Review fixes

* MM-60118 - Added index on ScheduledPosts table (#28579)

* Added index

* Updated indexes

* Scheduled posts misc fixes (#28625)

* Added detailed logging for scheduled post job

* Limited scheduled posts processing to 24 hours

* Marked old scheduled posts as unable to send

* Added t5ests

* converted some logs to trace level

* Fixed a bug causing error message to show up on deleting a scheduled post in a deleted thread (#28630)

* Fixed scheduled posts link in RHS (#28659)

* Fixed scheduled posts link in RHS

* Review fixes

* Fix permission name in scheduled posts by team (#28580)

* Fix permission name

* fix wording

---------

Co-authored-by: Mattermost Build <build@mattermost.com>

* FIxed width of generic modal header to fix browser channel modal (#28639)

* Only consider error-free scheduled posts for indicator in channel and RHS (#28683)

* Show only errro free scheudled posts in post box indicator

* Fixed a bug to handle no scheduled posts

* Fixed draft and scheudled post UI in mobile view (#28680)

* MM-60873 and MM-60872 - Fixed a bug with updating scheduled posts (#28656)

* Fixed a bug with updating scheduled posts

* Better selectors

* MOved shceuled post message length validation to app layer

* MM-60732 - Scheduled posts channel link now takes you to the first scheduled post in channel/thread in list (#28768)

* Ordered scheudle dposts by schgeudled at nad create at

* Ordered in client

* Added scroll to target

* Removed classname prop

* Fixed tests

* Added doc

* Import fix

* MM-60961 - Fixed a bug where API used incoming create at date for scheduled post (#28703)

* Fixed a bug where API used incoming create at date for scheduled post

* Stopped sending created at value for scheduled post

* MM-60785 - Fixed a bug where scheduled posts of channel we are no longer member of didn't show up (#28637)

* Fixed a bug where scheduled posts of channel we are no longer member of didn't show up

* Added a comment

* CI

* Used data loader to optimise laoding missing channels

* Minor refactoring

* MM-60963 - Added common checks for post and scheduled posts (#28713)

* Added commen checks for post and scheuled posts

* Sanitised scheduled posts

* Fixed tests

* Splitted post checks into app and context functions

* Added checks on scheduiled posts job as well:

* i18n fix

* Fixed a test

* Renamed a func

* removed duplicate check

* Scheduled posts UI fixes (#28828)

* Fixed send button and time picker borders

* Fixed center alignment of time picker

* Removed on for today and tomorrow

* Lint fix

* Date time modal hover state fix

* Badge fix

* Fixed a mnerge issue

* Scheduled Post send now and add schedule on draft (#28851)

* Added send now option on scheduled posts

* Minor refactoring

* WIP

* WIP

* WIP

* Lint fix

* i18n fix

* Snapshot update

* Review fixes

* Scheduled post inline editing (#28893)

* Added send now option on scheduled posts

* Minor refactoring

* WIP

* WIP

* WIP

* Lint fix

* i18n fix

* Snapshot update

* Displayed editing component in scheduled post

* Added handling for updating scheduled post

* Handle events

* Fixed escape key issue in scheudled post editing

* Fixes

* Displayed error message for editing error

* Don't show mention warning

* Handled dev mode (#28918)

* MInor fixes

* client fix

* Fixes

* CI

* Removed dev mode behaviour temperorily (#29008)

---------

Co-authored-by: Daniel Espino García <larkox@gmail.com>
Co-authored-by: Eva Sarafianou <eva.sarafianou@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-11-04 11:39:35 +05:30
Ibrahim Serdar Acikgoz
f41d2d7774
[MM-58745] export/import: enable exporting and importing bots canonically (#28214) 2024-11-01 19:44:30 +01:00
Arya Khochare
30076fcfcf
Fixed errcheck issues in server/channels/api4/webhook_test.go (#28573)
* errcheck issues fixed

* test bug fixed

* error to NoError

* test error fix

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
2024-11-01 14:11:04 +00:00
Ben Schumacher
2d2c039a27
[MM-61071] Fix errcheck issues in channels/app/admin.go (#28756) 2024-10-31 14:59:32 +01:00
Harshit Vashisht
fd70b0a0cd
Fixes errcheck in helper_test.go (#28909) 2024-10-29 16:16:58 +01:00
fume4mattermost
a44b604752
[MM-56032] Add tests for data_retention endpoints (#28283)
Co-authored-by: Fume <contact@fumedev.com>
2024-10-29 16:04:56 +01:00
Arya Khochare
e0e5dbd36e
Prevent HEAD requests to a sub-path from infinite redirects (#28285)
* adding test

```release-note
NONE
```

---------

Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-29 19:57:20 +05:30
Ben Schumacher
2424358b7d
[MM-61302] Use model.NewPointer throughout the code base (#28957) 2024-10-29 13:29:53 +01:00
Domendra Singh Komra
7803c10785
Fix errcheck issues in server/channels/jobs/batch_report_worker.go (#28864)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-29 10:50:54 +01:00
Matthew Straughn
71bf7777f5
fixed most init errors in channels/store/storetest dir | 24 files edited (#26522)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2024-10-29 10:50:38 +01:00
Ranjana761
5dba6e082d
Fix errcheck issues in server/channels/web/web.go (#28911) 2024-10-29 08:45:40 +01:00
Samarth Mishra
c7e182013f
Fix errcheck issues in server/channels/app/imaging/utils_test.go (#28960) 2024-10-29 08:37:32 +01:00
Claudio Costa
b4f337f191
[MM-60886] Fix TypeAssertionError in api4.addChannelMember (#28976)
* Fix TypeAssertionError in api4.addChannelMember

* Fix
2024-10-28 12:52:23 -06:00
Guillermo Vayá
a532b70317
[MM-59361] custom groups & read only channels (#28892)
* added group mention, read only view and post event tracking

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-28 13:41:29 +01:00
Agniva De Sarker
21c6b246f0
MM-61225: Remove incorrect test (#28954)
This test actually tested that there is no race
_if_ session pooling is there. But there is no session pooling
any more so this test is irrelevant.

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

```release-note
NONE
```
2024-10-25 21:53:03 +05:30
Dishika Vaishkiyar
4f5a389185
Fix: bot_test errcheck issue (#28822)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-25 13:31:03 +02:00
Ibrahim Serdar Acikgoz
64b30abbce
[MM-51487] allow uppercase team/channel names for import (#28906) 2024-10-25 09:44:13 +00:00
RuhiJain
49be26ebc4
Fix errcheck issues in server/channels/web/response_writer_wrapper_te… (#28902) 2024-10-25 11:26:08 +02:00
shraddha761
ca84f9a0b9
Fix errcheck issues in server/channels/utils/fileutils/fileutils_test.go (#28919) 2024-10-25 09:38:51 +02:00
Arya Khochare
323e330932
Fixed errcheck issues in server/channels/app/group_test.go (#28938) 2024-10-25 09:36:58 +02:00
Arya Khochare
fbdf3cbd14
Fixed errcheck issues in server/channels/api4/license_local.go (#28558)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-24 19:53:48 +02:00
Miguel de la Cruz
cb03009992
Adds a feature flag to control availability of DMs in shared channels (#28920)
* Adds a feature flag to control availability of DMs in shared channels

* Reverse feature flag wording
2024-10-24 19:38:00 +02:00
Agniva De Sarker
6075b1cd4e
MM-61225: Revert session pooling (#28901)
This originated from https://github.com/mattermost/mattermost/issues/15249.

However, the original idea was discarded https://github.com/mattermost/mattermost/issues/15249#issuecomment-709713065
as being too complicated to implement. Then I had another
idea to implement it just for session objects.

My thinking was that since every single request allocates a new
session struct, it would be good to use a sync.Pool for that.

However, 4 years later, now we know that the primary bottleneck
in app performance comes from websocket event marshalling.
Therefore, while it would be good to do this, it is difficult
to do it correctly (as shown by the numerous racy tests).

Hence, reverting this.

```release-note
NONE
```
2024-10-24 22:50:44 +05:30
Rohan Sharma
ebb0178c13
[MM-61103] Fix errcheck issues in server/channels/app/channel_category_test.go (#28790)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-24 13:58:01 +02:00
Domendra Singh Komra
834d94ab39
Fix errcheck issues in server/channels/jobs/batch_migration_worker.go (#28832) 2024-10-24 12:14:23 +02:00
fume4mattermost
48c42fc588
[MM-56035] Added missing unit tests for user endpoints (#28237)
Automatic Merge
2024-10-24 00:47:11 +02:00
Johnson
131064596d
fix errcheck issues (#28560)
* fix errcheck issues

* fix errcheck

* fix errcheck issues

* fix errcheck

* fix errcheck
2024-10-23 04:30:56 -07:00
Devin Binnie
0c90b0363b
[MM-60609][MM-60612] Include Desktop App metrics in PerformanceReporter, add metrics in Prometheus for CPU/Memory usage (#28825)
* [MM-60609][MM-60612] Include Desktop App metrics in PerformanceReporter, add metrics in Prometheus for CPU/Memory usage

* Fix mocks

* PR feedback
2024-10-22 12:16:20 -04:00
Daniel Espino García
2d96053012
Use flags for create post (#28857)
* Use flags for create post

* Remove unintended file

* Fix unintended change and types

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-22 16:00:26 +02:00
Vishal
cc5b3a2f69
[MM-37585] (#28634)
* add tests

* pass userID to the function instead of the user object.

* remove concurrent login simulation

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-22 12:21:36 +05:30
Agniva De Sarker
64677dd554
MM-42810: Using websocket broadcast hook for permalink preview (#28627)
We use the newly introduced websocket broadcast hook system
to implement permalink preview efficiently. This is essentially
a re-do of https://github.com/mattermost/mattermost/pull/23812
using the new system.

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

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-21 09:35:32 +05:30
Miguel de la Cruz
30cb527cf6
Forbid users from creating DMs and GMs with remote users (#28855)
* Forbid users from creating DMs and GMs with remote users

This change prevents the application from creating new DMs and GMs
when remote users are involved, and prevents as well new posts from
being created into preexisting DMs and GMs with remote users created
in previous versions.

* Adds i18n

* Skip preexisting DM tests and create a new one for the new behavior
2024-10-18 11:16:29 -06:00
Miguel de la Cruz
b4d8b6239c
Excludes remote channels from channel search (#28708)
* Excludes remote channels from channel search

This is done through a new body parameter in the SearchAllChannels
endpoint that allows to search for local only channels, which are
either channels that are shared but marked as homed locally, or
channels that are not shared at all.

* fix lint

* Fix tests

---------

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2024-10-18 07:41:24 -06:00
Caleb Roseland
fcded9559c
MM-61032: Add default_team_id to accept invite flow (#28841)
* add default_team_id to accept invite api

* add team selector to accept invite flow UI

* e2e

* lint/i18n
2024-10-18 12:26:38 +02:00
Miguel de la Cruz
5a923e0b94
Updates the create remote cluster endpoint to require a default team id (#28709)
Support for RemoteClusters without a default team id is in place for
old servers that created those connections before v10.1. This change
forbids the creation of new RemoteClusters without providing this
field, and will be removed when manual invites are implemented.

Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2024-10-18 12:22:27 +02:00
Scott Bishel
ad50357792
change Get() to use Master (#28842)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-18 12:19:43 +02:00
TheInvincible
bfd1d49e06
Fix errcheck issue in subpath_test.go (#28791)
* Fix errcheck issue in subpath_test.go

* Fix govet error

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-18 11:59:49 +05:30
Caleb Roseland
e6d6881917
MM-60980: Add RemoteClusterInvite.IsValid (#28624)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-17 20:37:11 -05:00
Arya Khochare
73fc99b577
errcheck issues fixed (#28646)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-17 15:22:01 +02:00
TheInvincible
0cb2475ea4
Fix errcheck issue in handlers.go (#28794) 2024-10-17 12:37:41 +02:00
Elias Nahum
f8f998bfcb
set update_at on bookmarks return when changing sort order (#28807)
* set update_at on bookmarks return when changing sort order

* update bookmarks sort order test
2024-10-17 07:42:19 +02:00
M-ZubairAhmed
48cde8c0bf
[MM-60655] Issue in subpath hosting after changes in root.html (#28617) 2024-10-17 01:13:16 +00:00
Rohan Sharma
df925a3e6b
fix: Scheme test errcheck issues (#28553)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-16 16:30:09 -05:00
Pratham Mahajan
f1250eaadb
Fix errcheck issues in server/channels/api4/export_test.go (#28815)
* Fix errcheck issues in server/channels/api4/export_test.go

* fixed lint errors

* fix
2024-10-16 17:33:56 +02:00
Scott Bishel
5dc86d5010
MM-56775 Limit Bookmarks Title and URL (#28424)
* additional validation for channelbookmark

* add fixes for webapp

* only set permissions correct for type

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-16 08:26:53 -06:00
TheInvincible
9726eedbe2
Update license.go (handled error) (#28410)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-16 09:45:41 +02:00
Arya Khochare
b0cdc51aa4
errcheck issues fixed (#28572)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-15 12:46:06 +02:00
Matthew Straughn
bc934007dc
Update message when password does not match requirement (#28178)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
2024-10-15 10:31:01 +02:00
Pradeep Murugesan
3f6bc5084b
check errors in channels/api4/channel.go (#28376)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-15 10:30:12 +02:00
Rohan Sharma
e27867cec7
fix: status errcheck issues (#28540)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-15 08:52:03 +02:00
Ben Schumacher
ff6de4bdab
Fix errcheck issues in channels/app/admin_test.go (#28767) 2024-10-14 21:05:39 +02:00
Agniva De Sarker
a190fe8503
MM-59947: Remove the remaining **model.User special casing (#28707)
We remove the remaining special casing for **model.User
and add unit tests to lock in the behavior.

Additional load tests were done locally to confirm
there are no hidden code paths left out.

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

```release-note
NONE
```
2024-10-14 21:03:01 +05:30
TheInvincible
dfa29c2b59
fix errcheck issue (#28618)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-14 13:33:50 +02:00
Ben Schumacher
7ff22436dc
[MM-60685] Fix racy TestSyncLdap (#28324) 2024-10-14 13:04:48 +02:00
Arya Khochare
b7ccd745c8
Fixed errcheck issues in server/channels/api4/oauth_test.go (#28645)
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2024-10-14 12:29:37 +02:00
Rohan Sharma
abf60421b4
fix: role test errcheck issues (#28545)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-14 09:55:34 +02:00
Daniel Espino García
42c9905e16
Update root post update at on reply delete (#28688)
* Update root post update at on reply delete

* Address feedback
2024-10-11 21:32:17 +02:00
Arya Khochare
d6343832d9
errcheck issues fixed (#28643) 2024-10-11 18:26:40 +02:00
k srisri reddy
bafe37d4b2
MM-60926: updated system_test.go to pass linter (#28691) 2024-10-11 16:18:19 +02:00
Arya Khochare
dd6546bd5e
errcheck issues fixed (#28693) 2024-10-11 16:16:46 +02:00
Ibrahim Serdar Acikgoz
9d5993d89d
[MM-58834] Review user preferences export and import (#28286) 2024-10-11 12:28:37 +02:00
Agniva De Sarker
df08325ef6
store: use ToSQL (#28681)
- Improve some code to use ToSQL
- Fix a bug in SqlReactionStore.GetForPostSince
where OrderBy wasn't added properly. Added a test.
- Improve a method to return a slice rather than
pass a pointer to slice.

```release-note
NONE
```
2024-10-11 09:11:38 +05:30
Agniva De Sarker
a258fd80b2
Remove remaining references to model.NewXX (#28678)
And we remove the deprecated functions to force uses
only of the new function.
```release-note
NONE
```
2024-10-10 22:15:22 +05:30
Agniva De Sarker
3db139f746
Removed the max/min family of functions (#28679)
They are in-built in Go now
```release-note
NONE
```
2024-10-10 22:14:21 +05:30
Pablo Vélez
6cafd45fc9
MM 57516 - deactivate actions to ldap users (#28199)
* MM-57516 - restrict activation/deactivation over ldap users

* Add unit tests

* refactor test to unify repeated actions

* add disable actions in user details too

* migrate test to use react-testing-library

* add new ldap user test and fix other existing tests

* restrict ldap users status management via api

* use correct server status and update tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-09 18:59:53 +02:00
Arya Khochare
ac38f5f751
Errcheck issues fixed in server/channels/api4/brand.go (#28362)
* errcheck proper error handling

* write response err check log

* resolving conflicts and io.Copy error handling
2024-10-09 18:43:34 +02:00
Rohan Sharma
e41ab1a3b8
fix: plugin errcheck issues (#28517)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-09 14:56:22 +02:00
Caleb Roseland
0f200adbe0
MM-58349: Shared Channels in System Console (#28116)
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
2024-10-09 07:53:19 -05:00
Rohan Sharma
02e6851603
fix: status test errcheck issues (#28541)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-09 14:51:19 +02:00
Arya Khochare
90ceb4a5e3
Fixed errcheck issues in server/channels/api4/usage_test.go (#28644)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-09 13:28:36 +02:00
TheInvincible
b49d86c24d
fix errcheck issue (#28548)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-09 13:27:39 +02:00
Rohan Sharma
65bb1a3427
fix: plugin test errcheck issues (#28531)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-09 12:26:23 +02:00
Rohan Sharma
68404f2f33
fix: scheme errcheck issues (#28543) 2024-10-09 11:58:16 +02:00
Arya Khochare
d1962e123e
[MM-60932] Fix errcheck issues in server/channels/api4/usage.go (#28641) 2024-10-09 11:53:25 +02:00
Johnson
33af22b2d3
Integration action test (#28561)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-08 15:41:01 +00:00
Miguel de la Cruz
3466e6f5d8
Avoid using token from sanitized remote cluster (#28335)
After creating a remote cluster, we were using its token field to
generate the remote invite. As we're going to return that remote
cluster in the response, we sanitize the entity, emptying the token
field before generating the invite, and causing it not to contain the
token itself.

This changes store the token in an independent variable to avoid
mutating it as part of the sanitization.

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-08 16:49:33 +02:00
Ben Cooke
b3c7ef0b97
[MM-56073] MMCTL delete post command (#27539)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-08 16:45:31 +02:00
TheInvincible
a671f80d2c
Fix errcheck issue for saml.go file (#28546)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-08 14:13:59 +00:00
Rohan Sharma
2b723099a6
fix: shared channel test errcheck issues (#28551)
* fix: shared channel test errcheck issues
2024-10-08 09:45:43 -04:00
Arya Khochare
f0918e1c01
errcheck issues fixed (#28609) 2024-10-08 12:23:08 +02:00
Diamond Rivero
71d98443c3
Fix Errcheck issues in server/channels/api4/export.go (#28407)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-08 10:47:17 +02:00
Arya Khochare
ba02101bcf
Fixed errcheck issues in server/channels/api4/group_local.go (#28417)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-08 10:47:01 +02:00
Rohan Sharma
9d6adbfea2
fix: role errcheck issues (#28544)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-08 10:46:22 +02:00
TheInvincible
1d431e72ac
Update emoji_test.go (fix errcheck issue) (#28440)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-08 09:31:26 +02:00
Rohan Sharma
845159d501
fix: reaction errcheck issues (#28513) 2024-10-08 09:25:34 +02:00
Rohan Sharma
1f3eab8adb
fix: team errcheck issues (#28550) 2024-10-08 09:23:53 +02:00
Arya Khochare
1669a0869f
errcheck issues fixed (#28555) 2024-10-07 21:20:18 +02:00
Arya Khochare
6837b31fb1
errcheck issues fixed (#28556) 2024-10-07 21:18:20 +02:00
Arya Khochare
82929d86ab
Errcheck issues fixed (#28409)
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2024-10-07 21:17:21 +02:00
CarlssonFilip
b8b3f9b012
[GH-28396] Fixed errcheck issues in server/channels/api4/ip_filtering.go (#28441)
* Fixed errcheck issues in server/channels/api4/ip_filtering.go

* Added separate go routine to SendIPFiltersChangedEmail and removed redundant return

* Added import for mlog

* Changed from returning error to logging it

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-07 21:03:12 +02:00
Rohan Sharma
7af408679e
Fix: emoji errcheck issues (#28437)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-07 21:02:16 +02:00
Rohan Sharma
9e0d629ab1
fix: team local errcheck issues (#28538)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-07 21:01:13 +02:00
Jesse Hallam
e9968792b0
Emit license details to logs when added or removed (#28333)
* log when changing the license

* handle test licenses without features or customer data

* skip logLicense if logger not setup
2024-10-07 12:48:03 -03:00
Arya Khochare
9b6d2be129
Errcheck issues fixed (#28345) 2024-10-07 16:49:27 +02:00
Rohan Sharma
a2acee5280
fix: system errcheck issues (#28537)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-07 13:37:46 +00:00
Rohan Sharma
2b7b4100d2
fix: system local errcheck issues (#28539)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2024-10-07 11:39:06 +00:00
Guillermo Vayá
662e59865c
MM-59360 add telemetry for paid features related to guests (#28295)
* add telemetry for paid features related to guests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-07 13:30:19 +02:00
Rohan Sharma
18388a8c64
fix: shared channel errcheck issues (#28542) 2024-10-07 12:46:00 +02:00
Arya Khochare
344e76287f
Fixed errcheck issues in server/channels/api4/license_test.go (#28557) 2024-10-07 12:41:13 +02:00
Rohan Sharma
13959b024f
fix: reaction test errcheck issues (#28516)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-07 10:31:06 +02:00
Arya Khochare
af9eb197ae
Fixed errcheck issues in server/channels/api4/group.go (#28404) 2024-10-05 12:23:29 +02:00
Ben Schumacher
88a805351e
[MM-57991] Add log message about deleted rows from Data Retention job (#26847) 2024-10-05 11:39:43 +02:00
Arya Khochare
5a7385295c
errcheck issues fixed (#28475) 2024-10-04 19:12:32 +02:00
Arya Khochare
0a92eb6363
errcheck issues fixed (#28418) 2024-10-04 17:51:38 +02:00
Nils
ac30b9d468
Fixed errcheck in server/channel/api4/job.go (#28420) 2024-10-04 17:50:14 +02:00
Arya Khochare
b859ca2d90
errcheck issues fixed (#28416) 2024-10-04 09:35:53 +02:00
Arya Khochare
7e62197520
errcheck issues fixed (#28476) 2024-10-04 09:34:29 +02:00
fume4mattermost
5f48a359ca
[MM-56033]Added unit tests for UpdateUserCustomStatus and RemoveUserCustomStatu… (#28216)
* added unit tests for UpdateUserCustomStatus and RemoveUserCustomStatus functions

* stylistic improvements in status endpoint tests

* linting fix

---------

Co-authored-by: Fume <contact@fumedev.com>
2024-10-04 13:02:53 +05:30
Arya Khochare
295ae8baed
Errcheck issues fixed (#28406)
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-04 07:14:48 +02:00
Arya Khochare
cab714a629
errcheck issues fixed (#28477) 2024-10-04 07:11:24 +02:00
Ben Schumacher
f3eee28f56
[MM-60253] Avoid unnecessary cache clearing during LDAP sync (#28300) 2024-10-03 16:26:53 +02:00
Daniel Espino García
da6b40665a
Avoid resetting device id when removed from push proxy (#28269)
* Avoid resetting device id when removed from push proxy

* Fix test and minor improvements

* Add MySQL support
2024-10-03 10:09:25 +02:00
Scott Bishel
0048723ccd
MM-60679 - Validate playbook plugin version, based on license (#28366)
Automatic Merge
2024-10-02 20:14:32 +02:00
Arya Khochare
9c2a9c7f26
Fixed errcheck issues (#28405) 2024-10-02 15:32:49 +02:00
Pablo Vélez
1690e48db6
MM 60222 - apply filter to export csv (#28212)
* MM-60222_apply filter to export csv

* get the report exporting with the filters ready

* add unit tests

* cover one more file with some tests

* style the confirm modal note

* add translations

* remove unnecessary print line

* disable export button if there is no data to export

* fix linter issues

* fix linter errors

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-10-02 12:23:39 +02:00
Arya Khochare
2b03afdfc2
Fixed errcheck issues (#28403) 2024-10-02 12:16:10 +02:00
Nils
887c3a800d
[GH-28355] Fixed errcheck issues in server/channels/api4/channel_category.go (#28357) 2024-10-02 09:50:43 +02:00
Miguel de la Cruz
acc9093072
Error when generating invite codes for a confirmed remote cluster (#28337) 2024-10-02 00:37:04 -05:00
Harrison Healey
76021c76a0
MM-60351 Use oEmbed for YouTube links (#28312)
* Split up handling of permalinks and other links in getLinkMetadata

* MM-60351 Use oEmbed for YouTube links

* Explicitly request json from the oEmbed provider

* Fix linter

* Fix type of CacheAge field

* Address feedback
2024-10-01 14:06:45 -04:00
Arya Khochare
23d06d4520
Errcheck issues fixed in server/channels/api4/brand_test.go (#28364) 2024-10-01 16:34:01 +02:00
CarlssonFilip
c5a504883d
[GH-28353] Fix errcheck issues in server/channels/api4/channel_bookmark_test.go (#28358) 2024-10-01 13:02:56 +02:00
Ben Schumacher
2b426573cd
[MM-60619] Annotate cluster logs messages (#28268) 2024-09-27 09:17:16 +02:00
Devin Binnie
d58b048965
[MM-60603] Don't follow threads when marking them as read on focus (#28263)
* [MM-60603] Don't follow threads when marking them as read on focus

* Fix tests

* Fix lint

* Fix the original bug in the API call
2024-09-26 09:02:11 -04:00
Ben Schumacher
3428cd15b6
[MM-60648] Don't start server until all routes are registered (#28291) 2024-09-26 13:57:48 +02:00
Ben Schumacher
20ed58906a
[MM-60307] Check if session is nil before calling UpdateLastActivityAtIfNeeded (#28254) 2024-09-26 13:52:59 +02:00
Daniel Espino García
1e8ef05338
Fix missing profile messages on notification dashboards (#28297) 2024-09-25 12:07:24 +02:00
Agniva De Sarker
5a511a14ee
MM-60606: Respect allowFromCache flag in Channelstore.GetMany (#28290)
Setting the flag to false never worked, and it was never
caught because there wasn't an instance when this method
was called with allowFromCache=false.

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

```release-note
NONE
```
2024-09-25 13:54:57 +05:30
Agniva De Sarker
9447cb9074
MM-60171: Using a generic function to allocate values (#28245)
We sprinkle a bit of generic magic to refactor a lot
of duplicate code.

To avoid exposing unnecessary code, I duplicated the function
twice. But let me know if you have strong opinions about this.

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

```release-note
NONE
```


---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-09-25 10:00:14 +05:30
Harrison Healey
46cad5c552
MM-59854 Fully allow at mentions in message attachment field values and add E2E tests (#28018)
* Add descriptions to test cases for getNeededAtMentionedUsernames

* MM-59854 Load users who are at-mentioned in message attachment fields

* MM-59854 Add server support for at-mentioning users in message attachment fields

* Migrate support/external_commands from JS to TS

* MM-59584 Ensure that at-mentions never show in other message attachment fields

* MM-59584 Add E2E tests for how we load users based on at mentions

* Use new E2E test helpers in other places

* Update snapshots
2024-09-24 09:41:03 -04:00
Daniel Espino García
040838b056
Add metrics for mobile versions snapshots (#28191)
* Add metrics for mobile versions snapshots

* Add notifications disabled and fix lint

* Address feedback

* Verify all references to JobTypeActiveUsers

* Fix typos

* Improve platform values

* Add test and MySQL support
2024-09-24 12:02:19 +02:00
Agniva De Sarker
d45a54a8e9
MM-60480: Do not invalidate channel member cache on login (#28143)
On user login, we were aggressively clearing the channel member
cache when it wasn't necessary. There is no channel membership
info that is changing on a user login.

Additionally, we fix some more issues with pointer passing
to the cache. It's a known problem that our value passing
style isn't consistent when we fetch items from cache.
Sometimes we pass pointer-to-pointer, sometimes it's just a
pointer. This is also the reason for https://github.com/mattermost/mattermost/pull/27830.

We fix 2 such cases where we passed pointer-to-pointer
but didn't handle the special case inside the cache.
This time, we actually fix it in the app layer instead
of the cache layer and also add a test for good measure.

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

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-09-24 13:01:19 +05:30
Pablo Vélez
b798dd8106
MM-59950 - add deletedAt column to users export (#28137) 2024-09-23 15:15:50 +02:00
Guillermo Vayá
dfa1d1027b
MM-60415 ignore deactivated bots (#28184)
* ignore bot accounts when counting deactivated users

* moved query to squirrel

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>

* set is null right

* Run a different query depending on driver due to performance reasons.

---------

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2024-09-20 13:02:09 +02:00
Miguel de la Cruz
8a735f1b03
Add a specific error when inviting a remote cluster to a remote channel (#28255) 2024-09-19 14:27:41 -05:00
Ben Schumacher
40d2ae97f1
[MM-60307] Fix racy use of session in NewWebConn (#28195) 2024-09-19 14:10:17 +02:00
Caleb Roseland
d6c11d1d26
get channel id for bookmark files in ES/OS (#28221)
Co-authored-by: Miguel de la Cruz <mgdelacroix@gmail.com>
2024-09-19 11:57:10 +02:00
Agniva De Sarker
7be7a47fd3
MM-59933: Increment/Decrement the member count directly (#28196)
While using Redis, there is no need to invalidate
and then update the new count from the DB when
we know the exact number it is going to be incremented
or decremented by.

In that case, we can directly use Redis primitives
to update the cache and prevent yet another DB query.

To achieve this, we modify the LRU cache get/set
paths slightly to not marshal into byte slices
for *int64 values. This is needed for Redis to operate
the INCR/DECR commands.

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

```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-09-19 09:38:38 +05:30
Agniva De Sarker
75ed2860ac
MM-59934: Add Redis to CI and other improvements (#28164)
- Update library version.
- Added MaxFlush delay to help reduce CPU usage.
- Fall back to LRU cache for the caches which use SCAN.
- Added mattermost-redis and running for all api layer
tests in Postgres.

https://mattermost.atlassian.net/browse/MM-59934
```release-note
NONE
```
2024-09-18 19:13:44 +05:30