MM-61033: [Shared Channels] Removing a shared channel on one end should make the other remove the shared channel too (#30738)

Этот коммит содержится в:
catalintomai
2025-06-16 16:25:00 +02:00
коммит произвёл GitHub
родитель 7fad136933
Коммит ed3a6d6b91
6 изменённых файлов: 571 добавлений и 12 удалений

Просмотреть файл

@@ -32,6 +32,7 @@ const (
NotifyMinimumDelay = time.Second * 2
MaxUpsertRetries = 25
ProfileImageSyncTimeout = time.Second * 5
UnshareMessage = "This channel is no longer shared."
// Default value for MaxMembersPerBatch is defined in config.go as ConnectedWorkspacesSettingsDefaultMemberSyncBatchSize
)
@@ -304,6 +305,31 @@ func (scs *Service) notifyClientsForSharedChannelUpdate(channel *model.Channel)
scs.app.Publish(messageWs)
}
// postUnshareNotification posts a system message to notify users that the channel is no longer shared.
func (scs *Service) postUnshareNotification(channelID string, creatorID string, channel *model.Channel, rc *model.RemoteCluster) {
post := &model.Post{
UserId: creatorID,
ChannelId: channelID,
Message: UnshareMessage,
Type: model.PostTypeSystemGeneric,
}
logger := scs.server.Log()
_, appErr := scs.app.CreatePost(request.EmptyContext(logger), post, channel, model.CreatePostFlags{})
if appErr != nil {
scs.server.Log().Log(
mlog.LvlSharedChannelServiceError,
"Error creating unshare notification post",
mlog.String("channel_id", channelID),
mlog.String("remote_id", rc.RemoteId),
mlog.String("remote_name", rc.Name),
mlog.Err(appErr),
)
}
}
// OnReceiveSyncMessageForTesting is a wrapper to expose onReceiveSyncMessage for testing purposes
// isGlobalUserSyncEnabled checks if the global user sync feature is enabled
func (scs *Service) isGlobalUserSyncEnabled() bool {
cfg := scs.server.Config()
@@ -349,3 +375,8 @@ func (scs *Service) HandleSyncAllUsersForTesting(rc *model.RemoteCluster) error
func (scs *Service) OnReceiveSyncMessageForTesting(msg model.RemoteClusterMsg, rc *model.RemoteCluster, response *remotecluster.Response) error {
return scs.onReceiveSyncMessage(msg, rc, response)
}
// HandleChannelNotSharedErrorForTesting is a wrapper to expose handleChannelNotSharedError for testing purposes
func (scs *Service) HandleChannelNotSharedErrorForTesting(msg *model.SyncMsg, rc *model.RemoteCluster) {
scs.handleChannelNotSharedError(msg, rc)
}