mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/matrixinvite: save portal after setting mxid
This commit is contained in:
parent
72bacbb666
commit
99cfa0b53a
2 changed files with 14 additions and 7 deletions
|
|
@ -177,10 +177,7 @@ func (br *Bridge) handleGhostDMInvite(ctx context.Context, evt *event.Event, sen
|
|||
return
|
||||
}
|
||||
|
||||
didSetPortal := portal.setMXIDToExistingRoom(evt.RoomID)
|
||||
if resp.PortalInfo != nil {
|
||||
portal.UpdateInfo(ctx, resp.PortalInfo, sourceLogin, nil, time.Time{})
|
||||
}
|
||||
didSetPortal := portal.setMXIDToExistingRoom(ctx, evt.RoomID)
|
||||
if didSetPortal {
|
||||
message := "Private chat portal created"
|
||||
err = br.givePowerToBot(ctx, evt.RoomID, invitedGhost.Intent)
|
||||
|
|
@ -190,6 +187,12 @@ func (br *Bridge) handleGhostDMInvite(ctx context.Context, evt *event.Event, sen
|
|||
message += "\n\nWarning: failed to promote bot"
|
||||
hasWarning = true
|
||||
}
|
||||
if resp.PortalInfo != nil {
|
||||
portal.UpdateInfo(ctx, resp.PortalInfo, sourceLogin, nil, time.Time{})
|
||||
} else {
|
||||
portal.UpdateCapabilities(ctx, sourceLogin, true)
|
||||
portal.UpdateBridgeInfo(ctx)
|
||||
}
|
||||
// TODO this might become unnecessary if UpdateInfo starts taking care of it
|
||||
_, err = br.Bot.SendState(ctx, portal.MXID, event.StateElementFunctionalMembers, "", &event.Content{
|
||||
Parsed: &event.ElementFunctionalMembersContent{
|
||||
|
|
@ -242,7 +245,7 @@ func (br *Bridge) givePowerToBot(ctx context.Context, roomID id.RoomID, userWith
|
|||
return nil
|
||||
}
|
||||
|
||||
func (portal *Portal) setMXIDToExistingRoom(roomID id.RoomID) bool {
|
||||
func (portal *Portal) setMXIDToExistingRoom(ctx context.Context, roomID id.RoomID) bool {
|
||||
portal.roomCreateLock.Lock()
|
||||
defer portal.roomCreateLock.Unlock()
|
||||
if portal.MXID != "" {
|
||||
|
|
@ -253,5 +256,9 @@ func (portal *Portal) setMXIDToExistingRoom(roomID id.RoomID) bool {
|
|||
portal.Bridge.cacheLock.Lock()
|
||||
portal.Bridge.portalsByMXID[portal.MXID] = portal
|
||||
portal.Bridge.cacheLock.Unlock()
|
||||
err := portal.Save(ctx)
|
||||
if err != nil {
|
||||
zerolog.Ctx(ctx).Err(err).Msg("Failed to save portal after updating mxid")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,6 +361,6 @@ func (portal *PortalInternals) ToggleSpace(ctx context.Context, spaceID id.RoomI
|
|||
return (*Portal)(portal).toggleSpace(ctx, spaceID, canonical, remove)
|
||||
}
|
||||
|
||||
func (portal *PortalInternals) SetMXIDToExistingRoom(roomID id.RoomID) bool {
|
||||
return (*Portal)(portal).setMXIDToExistingRoom(roomID)
|
||||
func (portal *PortalInternals) SetMXIDToExistingRoom(ctx context.Context, roomID id.RoomID) bool {
|
||||
return (*Portal)(portal).setMXIDToExistingRoom(ctx, roomID)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue