Repository navigation
bridgev2: add option to delete unknown rooms once - #661
iFixRobots wants to merge 3 commits into
Conversation
|
2 potential issues found:
↑ Select any checkbox above to have Indent auto-fix the issue 2 issues already resolved
All required CI checks passed on
Select any unchecked box below to run or rerun that agent. Full resultsIndent Review Agent
|
| } | ||
| } | ||
| br.DB.KV.Set(ctx, database.KeyUnknownRoomsCleanedUp, "true") | ||
| log.Info(). |
There was a problem hiding this comment.
⚪️ Nit · Cleanup flag set despite failures
The flag is set even when failedCount > 0, so a transient homeserver or DB error leaves those rooms in place with no retry. Only set it when everything succeeded.
Found by Indent Review Agent
| } | ||
|
|
||
| func (br *Bridge) deleteUnknownRooms(ctx context.Context, rooms []id.RoomID) { | ||
| log := zerolog.Ctx(ctx) |
There was a problem hiding this comment.
⚪️ Nit · Re-check before deleting misses newly set management rooms
The room list is captured after Matrix.Start, so events are processed while the deletion goroutine runs. If a user runs set-management-room in a listed room (e.g. an old DM with the bot), it becomes their management room but is still deleted, since only Portal.GetByMXID is re-checked. With room yeeting it's deleted for everyone.
Found by Indent Review Agent
Some users still have rooms that the bridge bot is in but that have no portal behind them, left over from an old reset that recreated the whole portal set next to them. Sends there fail with
room is not a portal, and clients can open them for a contact instead of the real portal.This adds an opt-in
bridge.cleanup_unknown_roomsthat runs once per bridge database. At the end ofStartConnectors, before any logins are started, it lists the bridge bot's joined rooms and picks every room that isn't a portal, a user's management room or a login's space. Doing it before logins start matters because portals and spaces get their room created and joined before the room ID is saved. The deletes then run in the background, re-checking the portal table per room. A KV flag is set at the end so it doesn't run again. If the bridge stops mid-way, the next start picks it up again.Tested on a Beeper staging account with the Dummy bridge: of 3 portals and a login space, only the portal whose database row had been removed was deleted, and a later restart didn't run the cleanup again.
Tag
@indentto continue the conversation here.