1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-03-20 20:45:00 +02:00

don't redundantly send config chg messages to cluster nodes (#3090)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Doug Lauder 2022-05-19 15:59:04 -04:00 committed by GitHub
parent e01cf226cb
commit f874c3dce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 13 deletions

View File

@ -381,22 +381,14 @@ func (pa *PluginAdapter) WebSocketMessageHasBeenPosted(webConnID, userID string,
}
}
func (pa *PluginAdapter) sendMessageToAllSkipCluster(payload map[string]interface{}) {
// sendMessageToAll will send a websocket message to all clients on all nodes.
func (pa *PluginAdapter) sendMessageToAll(event string, payload map[string]interface{}) {
// Empty &mmModel.WebsocketBroadcast will send to all users
pa.api.PublishWebSocketEvent(websocketActionUpdateConfig, payload, &mmModel.WebsocketBroadcast{})
}
func (pa *PluginAdapter) sendMessageToAll(payload map[string]interface{}) {
go func() {
clusterMessage := &ClusterMessage{Payload: payload}
pa.sendMessageToCluster("websocket_message", clusterMessage)
}()
pa.sendMessageToAllSkipCluster(payload)
pa.api.PublishWebSocketEvent(event, payload, &mmModel.WebsocketBroadcast{})
}
func (pa *PluginAdapter) BroadcastConfigChange(pluginConfig model.ClientConfig) {
pa.sendMessageToAll(utils.StructToMap(pluginConfig))
pa.sendMessageToAll(websocketActionUpdateConfig, utils.StructToMap(pluginConfig))
}
// sendUserMessageSkipCluster sends the message to specific users.

View File

@ -13,7 +13,6 @@ type ClusterMessage struct {
EnsureUsers []string
}
//nolint:unparam // the `id` param is to key this function generic and handle more than just websocket messages
func (pa *PluginAdapter) sendMessageToCluster(id string, clusterMessage *ClusterMessage) {
b, err := json.Marshal(clusterMessage)
if err != nil {
@ -66,6 +65,7 @@ func (pa *PluginAdapter) HandleClusterEvent(ev mmModel.PluginClusterEvent) {
"id", ev.Id,
"payload", clusterMessage.Payload,
)
return
}
pa.sendTeamMessageSkipCluster(websocketActionUpdateBlock, clusterMessage.TeamID, clusterMessage.Payload)