This is in preparation to make the codebase
ready to use Redis. In Redis, iterating all
the keys at once is an expensive operation.
It is recommended to work on batches of keys.
Remove the Len method as it was unused.
I tried to repurpose the Keys method to iterate
on keys rather than returning all keys at once, but
it has other complicacies because the code calls
other cache functions on those keys, so to handle
the LRU cache properly, it becomes slightly more
painful.
For now, we keep it like this and rather collect
all keys from Redis and then return.
https://mattermost.atlassian.net/browse/MM-56987
```release-note
NONE
```
* [MM-56757] Expand NotificationsLog to include websocket and email, adding much more varied logging across the entire process
* Rework the status/notify prop calls
* Avoid some repetition in the logging calls
* Fix one log
* Wrap error
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* refactor: migrate getFormattedPostTime to utils
Move app.getFormattedPostTime to utils and export along with its struct
* Set batch notification post times to user TZ
* default useMilitaryTime to false in batched email
If there is an error reading the user's preference for useMilitaryTime,
default to false, as that should be the default value if the user never
sets it.
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
1. For file endpoints, a recent optimization added the ChannelID column
to be part of the fileinfo table. Therefore, we can skip the postID
and directly use the channelID.
2. For post endpoints, we reorder the sequence of calls such that
we get the channelID first, and use it to check the permission of the channel
rather than query the long way around by joining with the posts table
in the permissions query.
The benefit is that SessionHasPermissionToChannel is cache-backed.
So in the happy path, we save a DB call. Because GetSinglePost anyways
needed to be called.
And in the bad path, we replace it with a more efficient call. Because
SessionHasPermissionToChannel is cache-backed, so effectively we
are replacing SessionHasPermissionToChannelByPost with GetSinglePost.
3. And then for the calls that don't have the channelID available,
we change the implementation itself to get the channelID by querying
the posts table first, and then calling SessionHasPermissionToChannel.
This creates the happy path as mentioned earlier.
While here, we also do some other optimizations:
4. Pre-populate the channelID while saving the reaction, so that
we don't need to query the posts table for every single reaction save.
5. Remove unnecessary goroutine spawning for publishing reaction events,
because anyways those are asynchronous.
https://mattermost.atlassian.net/browse/MM-56877
```release-note
NONE
```
Co-authored-by: Mattermost Build <build@mattermost.com>
* Add 'Disable' config to CloudSettings to prevent the CWS backend from making calls to the Customer Portal
* Add custom error when disabled
* Make Disable setting cloud_restrictable
* Return 422 instead of 400
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* Use correct error in doInviteRemote
A Sentry crash report identified this nil pointer dereference:
https://mattermost-mr.sentry.io/issues/4930233067/events/eae438652c7b4335be2bbe19c977f680
Interestingly, the stack trace shows the actual crash happening in the
function deferred above this line, which makes sense, given that it's
accessing the returned value, which is now nil as well. However, the
origin of the crash is here, since it's using the previous appErr, which
at this point is ensured to be nil, instead of the error returned by
InviteRemoteToChannel. This makes the returned value that should have
been generated by responsef to no longer exist.
* Test inviting a remote to a channel shared with us
* Improve error when InviteRemoteToChannel fails
* Clarify that channel has remoteID
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
* gofmt
---------
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
* make group search on modal and invite to work like group mentions
* update tests for better coverage
* change it back to startsWith
* update test
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* Ensure p.Integration is not nil
A Sentry crash report showed that the check
p.Integration.URL != input.integration.URL
was dereferencing a nil pointer. At that point in the code,
input.Integration is known to be non-nil, but we still need to check
whether the original, p.Integration, is.
Crash report: https://mattermost-mr.sentry.io/issues/4918263046/events/5738b67edcee4c9c883d40f7d26563a6
* Test nil original integration and both nil
* Fix multiple timer issue in CopyButton by using useRef
This commit resolves a bug where rapidly clicking the Copy button in the CopyButton component would initiate multiple overlapping timers, leading to unpredictable copy state toggling. By utilizing useRef, we now ensure a single timer instance is managed and cleared appropriately, stabilizing the copy functionality.
* Remove null assignment to timerRef.current before setting new timeout
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
invalidateCacheForChannelPosts invalidated the pinned post count
and the lastPostTime cache.
But not all endpoints actually pins or unpins the post. That's only
possible via the UpdatePost or PatchPost methods. Therefore, we remove
the unnecessary cache invalidation.
This is also important because this gets called for every single
channel load, and every new post would invalidate this cache.
https://mattermost.atlassian.net/browse/MM-56925
```release-note
NONE
```
* Restrict post metadata to allow for potentially unsafe links
* Enhance tests to test tests.
* Restrict prop to only be active if set to 'true'
* Adress feedback.
* Fix existing test using invalid permalink.
* Fix more tests
We do not send the typing event when the originating
channel is not the active channel or active channel thread.
https://mattermost.atlassian.net/browse/MM-56201
```release-note
NONE
```
Co-authored-by: harshil Sharma <harshilsharma63@gmail.com>
Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
* POC for API handler opts modifier
* Made upload POSt api a file upload API
* Specified file upload local API
* Specified file upload local API
* Specified file upload API
* Simplified handler params
* Added basic security checks
* Fixed i18n
* used type for API handler options
* Removed limited reader from util deserializers (#26263)
* add new sections
* remove section related code
* add some todos
* convert team setting to functional component
* remove unused props from main_menu
* remove unused collapseModal
* create 2 sections files
* clean info section
* cleanup access tab
* further clean team info setting component
* fix input fields
* fix description input field
* reorganize files
* add team icon when there is no team image
* improve layout
* fix autofocus
* delete empty file
* add note related to learna bout teams link
* add edit icon
* add upload functionality
* finish image upload
* implement logic for handle save
* add remove icon button
* fix remove button color
* fix styling on image remove and upload
* fix image remove feature
* show remove image button dynamically
* fix height
* update haveImageChanges on handleTeamIconRemove cl
* fix spacing inside input
* fix cursor point
* access tab basis
* add some todo
* add baseline for client error
* handle desc and image client errors
* move folders
* rename section to tab
* move the name section to new file
* dedicated description component
* dedicated image section
* convert to functional component
* remove unnecessary fetchTeam
* remove havechanges state
* remove not needed folder
* rename from section to tab
* convert access tab to FC
* fix invite section input
* finalize team invite code section
* add checkbox
* add select_text_input
* finish allowed domains
* fix save changes panel style
* convert open_invite
* add logic for show save changes panel globally
* handle server errors
* combine client errors
* fix save changes issue
* clean colors used in css
* fix style
* fix type issues
* fix another type
* fix allowed domains
* fix type error
* add save changes panel to access tab
* add success state to save changes panel
* remove unused prop
* cleanup css
* fix save changes modal position
* fix title font size
* remove not used prop
* fix mobile view width
* fix mobile view
* add group constraint text
* handle invite code error
* update snapshots
* fix input height
* fix tests
* write tests for open_invite
* write tests for team_info_tab
* write tests for team_access_tab
* Refactor setTeamIcon test in teams.test.ts
* Refactor team access and team info tabs for save changes panel
* Add useEffect hook to set inviteId in AccessTab component
* fix lint
* fix lint
* fix i18
* remove old todo
* fix text
* fix css
* fix css
* fix padding
* fix mobile view
* update snapshot
* performance improvements
* fix type
* improve translation passing to components
* fix lint
* rename saving to editing
* fix empty allowed domains
* complete renaming of saving
* seperate AllowedDomainsSelect
* seperate InviteSectionInput
* fix i18n
* capitalize translation id
* final fix for i18n
* remove empty file
* fix lint and test
* fix rgb values
* remove action related types from index file
* add last_team_icon_update to Team type
* fix unnecessary null check operator
* fix more types
* add new features for text selector
* update text for select text input
* fix style issues on save changes
* fix lint check
* add animation for save changes panel
* remove unused type
* fix test
* fix theming issues
* fix MM-T385
* fix MM-T388
* fix MM-T387 and MM-T2341
* fix MM-T391
* Fix MM-T2318, MM-T2317, MM-T2312, MM-T2322, MM-T2335
* fix top padding
---------
Co-authored-by: Mattermost Build <build@mattermost.com>