Shared channels auto-share DM & group messages (#26097)
* option for auto inviting plugin to all shared channels. * auto-invite remotes to shared channels when flag set
Этот коммит содержится в:
@@ -78,7 +78,31 @@ func handleContentSync(ps *PlatformService, syncService SharedChannelServiceIFac
|
||||
return err
|
||||
}
|
||||
|
||||
if channel != nil && channel.IsShared() {
|
||||
shouldNotify := channel.IsShared()
|
||||
|
||||
// check if any remotes need to be auto-subscribed to this channel. Remotes are auto-subscribed to DM/GM's if they registered
|
||||
// with the AutoShareDMs flag set.
|
||||
if channel.Type == model.ChannelTypeDirect || channel.Type == model.ChannelTypeGroup {
|
||||
filter := model.RemoteClusterQueryFilter{
|
||||
NotInChannel: channel.Id,
|
||||
OnlyConfirmed: true,
|
||||
RequireOptions: model.BitflagOptionAutoShareDMs,
|
||||
}
|
||||
remotes, err := ps.Store.RemoteCluster().GetAll(filter) // empty list returned if none found, no error
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot fetch remote clusters: %w", err)
|
||||
}
|
||||
for _, remote := range remotes {
|
||||
// invite remote to channel (will share the channel if not already shared)
|
||||
if err := syncService.InviteRemoteToChannel(channel.Id, remote.RemoteId, remote.CreatorId, true); err != nil {
|
||||
return fmt.Errorf("cannot invite remote to channel %s: %w", channel.Id, err)
|
||||
}
|
||||
shouldNotify = true
|
||||
}
|
||||
}
|
||||
|
||||
// notify
|
||||
if shouldNotify {
|
||||
syncService.NotifyChannelChanged(channel.Id)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user