diff --git a/server/platform/services/sharedchannel/membership.go b/server/platform/services/sharedchannel/membership.go index 8903b217f6..b27fd897bd 100644 --- a/server/platform/services/sharedchannel/membership.go +++ b/server/platform/services/sharedchannel/membership.go @@ -322,7 +322,7 @@ func (scs *Service) syncMembershipBatchToRemotes(syncMsg *model.SyncMsg, remotes // Check if user profile needs to be synced doSync, _, sErr := scs.shouldUserSync(user, syncMsg.ChannelId, rc) if sErr == nil && doSync { - enrichedSyncMsg.Users[user.Id] = user + enrichedSyncMsg.Users[user.Id] = sanitizeUserForSyncSafe(user) } } } diff --git a/server/platform/services/sharedchannel/util.go b/server/platform/services/sharedchannel/util.go index 603f56ff3f..40ea67255f 100644 --- a/server/platform/services/sharedchannel/util.go +++ b/server/platform/services/sharedchannel/util.go @@ -48,6 +48,12 @@ func sanitizeUserForSync(user *model.User) *model.User { return user } +func sanitizeUserForSyncSafe(user *model.User) *model.User { + // Create a copy to avoid modifying the original user object + userCopy := *user + return sanitizeUserForSync(&userCopy) +} + const MungUsernameSeparator = "-" // mungUsername creates a new username by combining username and remote cluster name, plus