* MM-45956: Optimize FileInfo stats query
We Denormalize Post.ChannelId on FileInfo.ChannelId
```release-note
The file info stats query is now optimized by denormalizing the channelID column into the table itself. This will speed up the query to get the file count for a channel on clicking the RHS.
Migration times:
On a MySQL 8.0.31 DB with
1405 rows in FileInfo and 11M posts, it took around 0.3s
On a Postgres 12.14 DB with
1731 rows in FileInfo and 11M posts, it took around 0.27s
```
https://mattermost.atlassian.net/browse/MM-45956
* Fix incorrect usage of types pacakge
* Make platform packages properly expose their type definitions
* Have Boards, Channels, and Playbooks get types from platform packages properly
* Run type check for all web app packages in CI
* Fix incorrect job name
There is a standard IDNA2008 which defines how unicode characters
in domain names can be compared using UTS (Unicode Technical Standard) 46.
We use that to convert any links in messages to ASCII and
then compare with the domain list in config.
https://mattermost.atlassian.net/browse/MM-51486
```release-note
NONE
```
* Refactor audit log application.
* Fix incorrect API Usage for Auditing
* Fixups.
* Rename Object audit to Auditable. Some small fixes.
---------
Co-authored-by: Daniel Schalla <daniel@schalla.me>
fmt.Sprintf was badly optimized and in cases of heavy traffic,
it was in the hot path and caused a lot of allocations.
We sacrifice readability for performance here.
```
10:46:40-~/mattermost/mattermost-server/model] benchstat base.txt new.txt
goos: linux
goarch: amd64
pkg: github.com/mattermost/mattermost-server/v6/model
cpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
│ base.txt │ new.txt │
│ sec/op │ sec/op vs base │
EncodeJSON-8 2.061µ ± 1% 1.588µ ± 2% -22.93% (p=0.000 n=10)
│ base.txt │ new.txt │
│ B/op │ B/op vs base │
EncodeJSON-8 545.0 ± 0% 472.0 ± 0% -13.39% (p=0.000 n=10)
│ base.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
EncodeJSON-8 6.000 ± 0% 3.000 ± 0% -50.00% (p=0.000 n=10)
```
```release-note
Writes to websocket now take 13% less memory
and also 22% faster per message.
```
* short-circuit plugin activation steps if executable is not found
* improve error message by removing redundant ref to plugin and mor consise language about server environment
* Adding debugbar layer
* Adding sql debugbar info
* Make duration consistent across the debugbar lines
* Adding the debugbar/systeminfo endpoint
* Adding logs to the debugbar
* Improve the debugbar logger fields info
* Improving the debug bar architecture
* Allow to enable/disable debugbar in the backend
* Exposing the Debug Bar enable in the client config
* Adding more system information to the debugbar
* Adding params info to the store layer
* Organizing a bit the debugbar code in the server and adding some extra data to the system info api
* Adding debugbar email traces
* Changing the socket event name to 'debugbar'
* Adding explain support for the debugbar
* Adding missed file
* Omitting data related to the debugbar itself
* Removing unneeded functions
* Avoid arbitrary execution in explain api
* Moving debugbar inside the platform directory
* Replacing debugbar logger with a new logger Target
* Removed uneeded changes
* Fixing some linter errors
* Adding a debugbar log level to use it later for log events strictly related to the debug bar
* Fixing linter errors
* Fixing tests
* Adding i18n strings
Instead of being completely hardcoded, public key is now set at build time according to build tag (test key if `testlicensekey` tag is passed to go build, production key otherwise). A `isProdLicensePublicKey` is also available for determining if the prod license key is being used. It is needed for choosing whether to point to production or test environment CWS.
The test license key and CWS url values in this value are set to production values in this PR, but will be updated to the test values once we are ready to do the necessary updates to test environment spinwicks.
This ticket does a number of improvements to the email
batching code in general.
- Fix unbounded goroutines: We now send mails using a single
goroutine only. Since anyways the processing is asynchronous,
performance should not matter.
- Move the exit condition earlier: We have moved up the check
for the per-user email interval preference. This prevents
unnecessary DB calls from happening.
- Break from the loop properly: The objective was to not
send notifications if a user has viewed any channel since
a notification was queued. But there were 2 nested for loops
and we were breaking from just one and not the other. That is
correctly fixed now to prevent unnecessary DB calls.
- Gracefully shutdown the job: The batching task wasn't
properly shut down and could have notifications in-flight
which would have not got sent. We fix that now by cancelling
the task and waiting for it to finish.
https://mattermost.atlassian.net/browse/MM-50393
* MM-48627: Fix flaky testGetUptoNSizeFileTime
There was an issue with data clean up before
and after the tests.
https://mattermost.atlassian.net/browse/MM-48627
```release-note
NONE
```
* Lint fix and improvements
```release-note
NONE
```