bridgev2/userlogin: add blocking cleanup delete option
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled

This allows the caller to block until the cleanup actions are complete.
This commit is contained in:
Nick Mills-Barrett 2024-11-27 15:07:47 +00:00
commit b32def2b14
No known key found for this signature in database
GPG key ID: 31F23F2CF354937B

View file

@ -255,6 +255,7 @@ func (ul *UserLogin) Logout(ctx context.Context) {
type DeleteOpts struct {
LogoutRemote bool
DontCleanupRooms bool
BlockingCleanup bool
unlocked bool
}
@ -295,9 +296,17 @@ func (ul *UserLogin) Delete(ctx context.Context, state status.BridgeState, opts
ul.Bridge.cacheLock.Unlock()
}
backgroundCtx := context.WithoutCancel(ctx)
go ul.deleteSpace(backgroundCtx)
if !opts.BlockingCleanup {
go ul.deleteSpace(backgroundCtx)
} else {
ul.deleteSpace(backgroundCtx)
}
if portals != nil {
go ul.kickUserFromPortals(backgroundCtx, portals, state.StateEvent == status.StateBadCredentials, false)
if !opts.BlockingCleanup {
go ul.kickUserFromPortals(backgroundCtx, portals, state.StateEvent == status.StateBadCredentials, false)
} else {
ul.kickUserFromPortals(backgroundCtx, portals, state.StateEvent == status.StateBadCredentials, false)
}
}
if state.StateEvent != "" {
ul.BridgeState.Send(state)