Allows invites to be sent to offline remotes (#28176)

* Allows invites to be sent to offline remotes

Invites sent to remotes marked as offline will be stored as pending,
and when the remote comes back online, it will process the invites as
part of the synchronization process.

* Update condition name for excluding confirmed invites
Этот коммит содержится в:
Miguel de la Cruz
2024-09-13 10:54:51 +02:00
коммит произвёл GitHub
родитель d879927876
Коммит f41d54b336
7 изменённых файлов: 117 добавлений и 16 удалений

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

@@ -495,7 +495,9 @@ func (s SqlSharedChannelStore) GetRemotes(offset, limit int, opts model.SharedCh
query = query.Where(sq.Eq{"scr.RemoteId": opts.RemoteId})
}
if !opts.InclUnconfirmed {
if opts.ExcludeConfirmed {
query = query.Where(sq.Eq{"scr.IsInviteConfirmed": false})
} else if !opts.IncludeUnconfirmed {
query = query.Where(sq.Eq{"scr.IsInviteConfirmed": true})
}

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

@@ -393,7 +393,7 @@ func testDeleteSharedChannel(t *testing.T, rctx request.CTX, ss store.Store) {
ChannelId: channel.Id,
CreatorId: model.NewId(),
RemoteId: model.NewId(),
IsInviteConfirmed: true, // to avoid adding the InclUnconfirmed filter
IsInviteConfirmed: true, // to avoid adding the IncludeUnconfirmed filter
}
_, err := ss.SharedChannel().SaveRemote(remote)
require.NoError(t, err, "couldn't add remote", err)
@@ -688,8 +688,8 @@ func testGetSharedChannelRemotes(t *testing.T, rctx request.CTX, ss store.Store)
t.Run("Get shared channel remotes by remote_id including unconfirmed", func(t *testing.T) {
opts := model.SharedChannelRemoteFilterOpts{
RemoteId: remoteId,
InclUnconfirmed: true,
RemoteId: remoteId,
IncludeUnconfirmed: true,
}
remotes, err := ss.SharedChannel().GetRemotes(0, 999999, opts)
require.NoError(t, err, "should not error", err)
@@ -699,6 +699,19 @@ func testGetSharedChannelRemotes(t *testing.T, rctx request.CTX, ss store.Store)
}
})
t.Run("Get only unconfirmed shared channel remotes for remote", func(t *testing.T) {
opts := model.SharedChannelRemoteFilterOpts{
RemoteId: remoteId,
ExcludeConfirmed: true,
}
remotes, err := ss.SharedChannel().GetRemotes(0, 999999, opts)
require.NoError(t, err, "should not error", err)
require.Len(t, remotes, 1)
for _, r := range remotes {
require.False(t, r.IsInviteConfirmed)
}
})
t.Run("Get shared channel remotes with bad options", func(t *testing.T) {
opts := model.SharedChannelRemoteFilterOpts{
ExcludeHome: true,
@@ -739,8 +752,8 @@ func testGetSharedChannelRemotes(t *testing.T, rctx request.CTX, ss store.Store)
t.Run("Get shared channel remotes excluding shared from home including unconfirmed", func(t *testing.T) {
opts := model.SharedChannelRemoteFilterOpts{
ExcludeHome: true,
InclUnconfirmed: true,
ExcludeHome: true,
IncludeUnconfirmed: true,
}
remotes, err := ss.SharedChannel().GetRemotes(0, 999999, opts)
require.NoError(t, err, "should not error", err)