mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Add migration to set state event in all rooms
Some checks failed
Some checks failed
This commit is contained in:
parent
460c6fe75b
commit
7f9334d5df
2 changed files with 21 additions and 0 deletions
|
|
@ -35,9 +35,20 @@ type PortalQuery struct {
|
|||
*dbutil.QueryHelper[*Portal]
|
||||
}
|
||||
|
||||
type CapStateFlags uint32
|
||||
|
||||
func (csf CapStateFlags) Has(flag CapStateFlags) bool {
|
||||
return csf&flag != 0
|
||||
}
|
||||
|
||||
const (
|
||||
CapStateFlagDisappearingTimerSet CapStateFlags = 1 << iota
|
||||
)
|
||||
|
||||
type CapabilityState struct {
|
||||
Source networkid.UserLoginID `json:"source"`
|
||||
ID string `json:"id"`
|
||||
Flags CapStateFlags `json:"flags"`
|
||||
}
|
||||
|
||||
type Portal struct {
|
||||
|
|
|
|||
|
|
@ -3649,6 +3649,15 @@ func (portal *Portal) UpdateCapabilities(ctx context.Context, source *UserLogin,
|
|||
portal.CapState = database.CapabilityState{
|
||||
Source: source.ID,
|
||||
ID: capID,
|
||||
Flags: portal.CapState.Flags,
|
||||
}
|
||||
if caps.DisappearingTimer != nil && !portal.CapState.Flags.Has(database.CapStateFlagDisappearingTimerSet) {
|
||||
zerolog.Ctx(ctx).Debug().Msg("Disappearing timer capability was added, sending disappearing timer state event")
|
||||
success = portal.sendRoomMeta(ctx, nil, time.Now(), event.StateBeeperDisappearingTimer, "", portal.Disappear.ToEventContent())
|
||||
if !success {
|
||||
return false
|
||||
}
|
||||
portal.CapState.Flags |= database.CapStateFlagDisappearingTimerSet
|
||||
}
|
||||
portal.lastCapUpdate = time.Now()
|
||||
if implicit {
|
||||
|
|
@ -4342,6 +4351,7 @@ func (portal *Portal) createMatrixRoomInLoop(ctx context.Context, source *UserLo
|
|||
Type: event.StateBeeperDisappearingTimer,
|
||||
Content: event.Content{Parsed: portal.Disappear.ToEventContent()},
|
||||
})
|
||||
portal.CapState.Flags |= database.CapStateFlagDisappearingTimerSet
|
||||
}
|
||||
if req.Topic == "" {
|
||||
// Add explicit topic event if topic is empty to ensure the event is set.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue