Plugin API for Shared Channels: support auto invite (#25834)

* option for auto inviting plugin to all shared channels.

* auto-invite remotes to shared channels when flag set

* fix unit test

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Doug Lauder
2024-01-08 12:12:18 -05:00
коммит произвёл GitHub
родитель b05093d508
Коммит 000aa0d891
8 изменённых файлов: 69 добавлений и 6 удалений

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

@@ -79,7 +79,22 @@ func (scs *Service) syncForRemote(task syncTask, rc *model.RemoteCluster) error
}
scr, err := scs.server.GetStore().SharedChannel().GetRemoteByIds(task.channelID, rc.RemoteId)
if err != nil {
if isNotFoundError(err) && rc.IsOptionFlagSet(model.BitflagOptionAutoInvited) {
// if SharedChannelRemote not found and remote has autoinvite flag, create a scr for it, thus inviting the remote.
scr = &model.SharedChannelRemote{
Id: model.NewId(),
ChannelId: task.channelID,
CreatorId: rc.CreatorId,
IsInviteAccepted: true,
IsInviteConfirmed: true,
RemoteId: rc.RemoteId,
LastPostCreateAt: model.GetMillis(),
LastPostUpdateAt: model.GetMillis(),
}
if scr, err = scs.server.GetStore().SharedChannel().SaveRemote(scr); err != nil {
return fmt.Errorf("cannot auto-create shared channel remote (channel_id=%s, remote_id=%s): %w", task.channelID, rc.RemoteId, err)
}
} else if err != nil {
return err
}