mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* chore: remove deprecated shared channels feature flags * chore: remove sharedChannelsPluginsEnabled prop from channel header * chore: remove enableSharedChannelsPlugins prop from file_search_results and post_message_view * chore: drop hardcoded FeatureFlagEnableSharedChannelsPlugins from client config * fix: remove unused channel prop from file_search_result_item * fix: remove double blank line in file_search_result_item test * remove redundant fragment wrapper in channel header * Remove unused channelId prop from CodeBlock
58 lines
2.0 KiB
Go
58 lines
2.0 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package sharedchannel
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
)
|
|
|
|
func (scs *Service) isChannelMemberSyncEnabled() bool {
|
|
return scs.server.GetRemoteClusterService() != nil
|
|
}
|
|
|
|
// NotifyMembershipChanged is called when users are added or removed from a shared channel.
|
|
// It triggers a sync for the channel so that membership changes are picked up from
|
|
// ChannelMemberHistory at sync time, following the same pattern as posts and reactions.
|
|
// originRemoteID identifies the remote that initiated the change, so it can be skipped
|
|
// during sync to prevent echo-back.
|
|
func (scs *Service) NotifyMembershipChanged(channelID string, originRemoteID string) {
|
|
if !scs.isChannelMemberSyncEnabled() {
|
|
return
|
|
}
|
|
task := newSyncTask(channelID, "", "", nil, nil)
|
|
task.originRemoteID = originRemoteID
|
|
task.schedule = time.Now().Add(NotifyMinimumDelay)
|
|
scs.addTask(task)
|
|
}
|
|
|
|
// ForceMembershipSyncForRemote triggers a sync for all channels shared with the specified remote.
|
|
// Called when a remote comes back online to catch up on any membership changes that occurred
|
|
// while it was offline. The sync pipeline will read ChannelMemberHistory using the
|
|
// LastMembersSyncAt cursor to detect both additions and removals.
|
|
func (scs *Service) ForceMembershipSyncForRemote(rc *model.RemoteCluster) {
|
|
if !scs.isChannelMemberSyncEnabled() {
|
|
return
|
|
}
|
|
|
|
opts := model.SharedChannelRemoteFilterOpts{
|
|
RemoteId: rc.RemoteId,
|
|
}
|
|
scrs, err := scs.server.GetStore().SharedChannel().GetRemotes(0, 999999, opts)
|
|
if err != nil {
|
|
scs.server.Log().LogM(mlog.MlvlSharedChannelServiceError, "Failed to fetch shared channel remotes for membership sync",
|
|
mlog.String("remote", rc.DisplayName),
|
|
mlog.String("remoteId", rc.RemoteId),
|
|
mlog.Err(err),
|
|
)
|
|
return
|
|
}
|
|
|
|
for _, scr := range scrs {
|
|
scs.NotifyChannelChanged(scr.ChannelId)
|
|
}
|
|
}
|