From 8f95656c8f7398945f52ab974fbde123558edd59 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 22 May 2024 14:45:10 -0400 Subject: [PATCH] [MM-55485] Ensure user added to channel receives websocket event regardless of channel membership info retrieved in HA (#27013) * [MM-55485] Ensure user added to channel receives websocket event regardless of channel membership info retrieved in HA * Testing to see if group messages are also affected * Use context from master approach * Hardcode to master to test * Revert "Hardcode to master to test" This reverts commit 50ef2baed1559861367d9c3b4cea74c21b4b9fd1. * Revert "Use context from master approach" This reverts commit 65d3584f83559554213cd9c726258d80775bc8bd. * Remove group message changes, add comment --------- Co-authored-by: Mattermost Build --- server/channels/app/channel.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/channels/app/channel.go b/server/channels/app/channel.go index 27ac77c8e8..b4c17749fc 100644 --- a/server/channels/app/channel.go +++ b/server/channels/app/channel.go @@ -1597,11 +1597,19 @@ func (a *App) AddUserToChannel(c request.CTX, user *model.User, channel *model.C return nil, err } - message := model.NewWebSocketEvent(model.WebsocketEventUserAdded, "", channel.Id, "", nil, "") + // We are sending separate websocket events to the user added and to the channel + // This is to get around potential cluster syncing issues where other nodes may not receive the most up to date channel members + // There is likely some issue syncing these that needs to be looked at, but this is the current fix. + message := model.NewWebSocketEvent(model.WebsocketEventUserAdded, "", channel.Id, "", map[string]bool{user.Id: true}, "") message.Add("user_id", user.Id) message.Add("team_id", channel.TeamId) a.Publish(message) + userMessage := model.NewWebSocketEvent(model.WebsocketEventUserAdded, "", channel.Id, user.Id, nil, "") + userMessage.Add("user_id", user.Id) + userMessage.Add("team_id", channel.TeamId) + a.Publish(userMessage) + return newMember, nil }