Mattermost is an open source platform for secure collaboration across the entire software development lifecycle..
Go to file
Agniva De Sarker b20ef95b91
MM-42810: Introduce a channel hook for a websocket event (#23812)
Sometimes a broad distinction of just a channelID or a userID
is not enough to efficiently send a websocket event to users.

In several cases, depending on the user and channel, we might
need to modify the message. Therefore, we introduce the
concept of a channel hook that will get executed if the scope
is set to a channel. This hook can be populated at the app layer
to perform any application specific logic to the event.

Care must be taken to avoid race conditions as the passed event
is not deep copied. It is left to the user to treat it carefully.

For this issue, the main problem was that since we don't know
which users have permissions to which channels, we had to go through
_all_ members of a channel to figure that out. This was redundant
since a large portion of those users might not even be connected
at that time.

We solve this with the channel hook where we push this check
to be performed later while actually sending the event. This
reduces the computation to be done only for _connected_ users
rather than _all_ users of a channel.

The next iteration of this should be to use websocket subscriptions
to monitor exactly which users are on that channel to even
trim down that list. That is a larger initiative to be taken later.

Tested locally with a channel of 50 users. Here are rough results:
```
With PR:
patchPost 97ms
createPost 90ms

Master:
patchPost 306ms
createPost - 298ms
```

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

```release-note
Improve  performance while sending messages
with permalinks to channels with large number of users.
```
2023-07-15 08:14:16 +05:30
.github fix: Add e2e-tests paths for tests trigger (#23894) 2023-07-12 10:52:05 +03:00
api Update API repo links (#23883) 2023-06-27 16:53:52 -04:00
e2e-tests Debug smoketests (#23982) 2023-07-13 13:28:11 +02:00
server MM-42810: Introduce a channel hook for a websocket event (#23812) 2023-07-15 08:14:16 +05:30
webapp Fix New Messages toast showing when it should not (#23995) 2023-07-13 13:28:44 +02:00
.gitignore Merge branch 'master' into fix-boards-webapp-unit-tests 2023-03-29 09:37:24 -05:00
.gitlab-ci.yml Upgrade docker CI image to 23.0.1 (#23664) 2023-06-07 19:49:48 +03:00
.gitpod.yml Add .gitpod.yml to use mattermost-gitpod-config repo for Gitpod configuration (#19984) 2022-04-14 11:02:50 -04:00
.nvmrc Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
CHANGELOG.md Changelog link (#8805) 2018-05-30 10:23:25 -04:00
CODEOWNERS Add CODEOWNERS for migrations (#23020) 2023-04-19 20:01:50 +05:30
CONTRIBUTING.md Remove outdated information from contributing file (#10749) 2019-05-01 23:46:00 +02:00
LICENSE.txt update LICENSE.txt (#22659) 2023-03-27 10:54:06 -03:00
NOTICE.txt Update NOTICE.txt (#23857) 2023-06-28 14:59:07 -04:00
README.md [MM-52869] Update and fix links in the system console (#23694) 2023-06-19 18:46:52 +02:00
SECURITY.md MM-41988 Updated links to legacy domain about.mm.com (#19552) 2022-03-16 19:47:57 +08:00

Mattermost

Mattermost is an open source platform for secure collaboration across the entire software development lifecycle. This repo is the primary source for core development on the Mattermost platform; it's written in Go and React and runs as a single Linux binary with MySQL or PostgreSQL. A new compiled version is released under an MIT license every month on the 16th.

Use it for free in Mattermost Cloud or deploy on-premises.

mattermost-hero

Learn more about the following use cases with Mattermost:

Other useful resources:

Table of contents

Install Mattermost

Other install guides:

Native mobile and desktop apps

In addition to the web interface, you can also download Mattermost clients for Android, iOS, Windows PC, macOS, and Linux.

Google Play App Store Windows PC Mac OSX Linux

Get security bulletins

Receive notifications of critical security updates. The sophistication of online attackers is perpetually increasing. If you're deploying Mattermost it's highly recommended you subscribe to the Mattermost Security Bulletin mailing list for updates on critical security releases.

Subscribe here

Get involved

Learn more

License

See the LICENSE file for license rights and limitations.

Get the latest news

Contributing

Please see CONTRIBUTING.md. Join the Mattermost Contributors server to join community discussions about contributions, development, and more.