* Moved some common SQL function tu public utls as they are used in plugins
* goimported file
* Added tests
* Created sub-package
* MOved SetupConnection to public sql utils
While updating config from admin console, the webapp would set
any config param to null if the user doesn't have permission to edit
that setting.
This is common in cloud environments where a lot of config settings
are set to `cloud_restrictable`.
The problem due to that is since the client uses the updateConfig
endpoint, this acts as a full config replace and therefore, the null
fields get replaced by their default values.
To fix this, we use the patch endpoint which only updates the fields
that are actually set.
https://mattermost.atlassian.net/browse/MM-56625
```release-note
Fix a bug where config cannot be updated from admin console
in cloud environments.
```
Co-authored-by: Mattermost Build <build@mattermost.com>
Previously, we would setup both pools only when
GetMasterDB was called. This was inefficient and
would waste open connections if the replica wasn't used
at all.
We fix it to initialize the pools as they are called.
https://mattermost.atlassian.net/browse/MM-56402
```release-note
NONE
```
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
* don't allow guest to be set only on channels.
* fix bad merge, add jira ticket link
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
There were 3 remaining caches which were there in the store layer.
We migrate them to make the store layer fully free
from any caches.
https://mattermost.atlassian.net/browse/MM-56879
```release-note
NONE
```
Co-authored-by: Mattermost Build <build@mattermost.com>
* Move license setting from env var to mmctl upload
* Extract common E2E steps
* Add E2E fulltests
* Fix plugin_startup_fail_spec.js, timeout runners, fix local dashboard run
* Implement reporting script and job
* Bump artifact related actions
* Fix E2E variable generator script
* Skip reporting steps if not required
* Get rid of deprecation warnings
* Fix inbucket hostname parameter
* Support arbitrary refs in test template
* Fix cycle BRANCH var for non-PR commits
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* dont allow guests to be set via team API
* comment out invalid test
* Update import_functions_test.go
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* changed helper text to control-label class
* removed the help-text class
* added "helping-text" className
* Updated helping-text color
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
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>