mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Removing some other fake apps * More FakeApp removed * Removing entirely FakeApp * Fixing some tests * Fixing get Cluster id from get plugin status * Fixing failing tests * Fixing tests * Fixing test initialization for web * Fixing InitServer for server tests * Fixing InitServer for server tests * Reverting go.sum and go.mod * Removing unneded HTMLTemplates function in App layer * Moving back some functions to its old place to easy the review * Moving back some functions to its old place to easy the review * Using the last struct2interface version * Generating store layers * Fixing merge problems * Addressing PR comments * Small fix * Fixing app tests build * Fixing tests * fixing tests * Fix tests * Fixing tests * Fixing tests * Fixing tests * Moving license to server struct * Adding some fixes to the test compilation * Fixing cluster and some jobs initialization * Fixing some license tests compilation problems * Fixing recursive cache invalidation * Regenerating app layers * Fix test compilation Co-authored-by: mattermod <mattermod@users.noreply.github.com>
84 lines
3.8 KiB
Go
84 lines
3.8 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/mattermost/mattermost-server/v5/model"
|
|
)
|
|
|
|
// RegisterAllClusterMessageHandlers registers the cluster message handlers that are handled by the App layer.
|
|
//
|
|
// The cluster event handlers are spread across this function and
|
|
// NewLocalCacheLayer. Be careful to not have duplicated handlers here and
|
|
// there.
|
|
func (a *App) registerAllClusterMessageHandlers() {
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_PUBLISH, a.clusterPublishHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_UPDATE_STATUS, a.clusterUpdateStatusHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_ALL_CACHES, a.clusterInvalidateAllCachesHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS_NOTIFY_PROPS, a.clusterInvalidateCacheForChannelMembersNotifyPropHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_BY_NAME, a.clusterInvalidateCacheForChannelByNameHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER, a.clusterInvalidateCacheForUserHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER_TEAMS, a.clusterInvalidateCacheForUserTeamsHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER, a.clusterClearSessionCacheForUserHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_ALL_USERS, a.clusterClearSessionCacheForAllUsersHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INSTALL_PLUGIN, a.clusterInstallPluginHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_REMOVE_PLUGIN, a.clusterRemovePluginHandler)
|
|
a.Cluster().RegisterClusterMessageHandler(model.CLUSTER_EVENT_BUSY_STATE_CHANGED, a.clusterBusyStateChgHandler)
|
|
}
|
|
|
|
func (a *App) clusterPublishHandler(msg *model.ClusterMessage) {
|
|
event := model.WebSocketEventFromJson(strings.NewReader(msg.Data))
|
|
if event == nil {
|
|
return
|
|
}
|
|
a.PublishSkipClusterSend(event)
|
|
}
|
|
|
|
func (a *App) clusterUpdateStatusHandler(msg *model.ClusterMessage) {
|
|
status := model.StatusFromJson(strings.NewReader(msg.Data))
|
|
a.AddStatusCacheSkipClusterSend(status)
|
|
}
|
|
|
|
func (a *App) clusterInvalidateAllCachesHandler(msg *model.ClusterMessage) {
|
|
a.Srv().InvalidateAllCachesSkipSend()
|
|
}
|
|
|
|
func (a *App) clusterInvalidateCacheForChannelMembersNotifyPropHandler(msg *model.ClusterMessage) {
|
|
a.invalidateCacheForChannelMembersNotifyPropsSkipClusterSend(msg.Data)
|
|
}
|
|
|
|
func (a *App) clusterInvalidateCacheForChannelByNameHandler(msg *model.ClusterMessage) {
|
|
a.invalidateCacheForChannelByNameSkipClusterSend(msg.Props["id"], msg.Props["name"])
|
|
}
|
|
|
|
func (a *App) clusterInvalidateCacheForUserHandler(msg *model.ClusterMessage) {
|
|
a.invalidateCacheForUserSkipClusterSend(msg.Data)
|
|
}
|
|
|
|
func (a *App) clusterInvalidateCacheForUserTeamsHandler(msg *model.ClusterMessage) {
|
|
a.InvalidateWebConnSessionCacheForUser(msg.Data)
|
|
}
|
|
|
|
func (a *App) clusterClearSessionCacheForUserHandler(msg *model.ClusterMessage) {
|
|
a.ClearSessionCacheForUserSkipClusterSend(msg.Data)
|
|
}
|
|
|
|
func (a *App) clusterClearSessionCacheForAllUsersHandler(msg *model.ClusterMessage) {
|
|
a.ClearSessionCacheForAllUsersSkipClusterSend()
|
|
}
|
|
|
|
func (a *App) clusterInstallPluginHandler(msg *model.ClusterMessage) {
|
|
a.InstallPluginFromData(model.PluginEventDataFromJson(strings.NewReader(msg.Data)))
|
|
}
|
|
|
|
func (a *App) clusterRemovePluginHandler(msg *model.ClusterMessage) {
|
|
a.RemovePluginFromData(model.PluginEventDataFromJson(strings.NewReader(msg.Data)))
|
|
}
|
|
|
|
func (a *App) clusterBusyStateChgHandler(msg *model.ClusterMessage) {
|
|
a.ServerBusyStateChanged(model.ServerBusyStateFromJson(strings.NewReader(msg.Data)))
|
|
}
|