mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/legacymigrate: add post-migrate hook
Some checks failed
Some checks failed
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
parent
93b9509135
commit
74a02366d7
2 changed files with 15 additions and 4 deletions
|
|
@ -226,11 +226,18 @@ func (br *BridgeMain) PostMigrate(ctx context.Context) error {
|
|||
Object("portal_key", portal.PortalKey).
|
||||
Str("room_type", string(portal.RoomType)).
|
||||
Msg("Migrating portal")
|
||||
switch portal.RoomType {
|
||||
case database.RoomTypeDM:
|
||||
err = br.postMigrateDMPortal(ctx, portal)
|
||||
if br.PostMigratePortal != nil {
|
||||
err = br.PostMigratePortal(ctx, portal)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update DM portal %s: %w", portal.MXID, err)
|
||||
return fmt.Errorf("failed to run post-migrate portal hook for %s: %w", portal.MXID, err)
|
||||
}
|
||||
} else {
|
||||
switch portal.RoomType {
|
||||
case database.RoomTypeDM:
|
||||
err = br.postMigrateDMPortal(ctx, portal)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update DM portal %s: %w", portal.MXID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err = br.Matrix.Bot.SendStateEvent(ctx, portal.MXID, event.StateElementFunctionalMembers, "", &event.ElementFunctionalMembersContent{
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ type BridgeMain struct {
|
|||
PostInit func()
|
||||
PostStart func()
|
||||
|
||||
// PostMigratePortal is a function that will be called during a legacy
|
||||
// migration for each portal.
|
||||
PostMigratePortal func(context.Context, *bridgev2.Portal) error
|
||||
|
||||
// Connector is the network connector for the bridge.
|
||||
Connector bridgev2.NetworkConnector
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue