Skip to content

feat(bridgev2): receive room account data via double puppet /sync loop#481

Draft
kalix127 wants to merge 1 commit intomautrix:mainfrom
kalix127:fix/bridge-account-data-via-double-puppet-sync
Draft

feat(bridgev2): receive room account data via double puppet /sync loop#481
kalix127 wants to merge 1 commit intomautrix:mainfrom
kalix127:fix/bridge-account-data-via-double-puppet-sync

Conversation

@kalix127
Copy link
Copy Markdown

Draft: Manually tested on a real Synapse deployment with the WhatsApp bridge. Opening as draft for feedback on the approach.

Summary

  • Add account data syncer that runs a /sync loop as the double-puppeted user to receive room account data changes (m.marked_unread, m.tag, com.beeper.mute)
  • Synapse does not forward these events to appservices via the transaction API, so a separate sync loop is needed
  • Content-based dedup prevents loops: when the bridge sets account data via double puppet, the resulting sync echo is identified by matching JSON content and skipped
  • Add MarkAccountDataSent calls in intent methods (MarkRead, MarkUnread, TagRoom, MuteRoom) to track bridge-originated changes
  • Add AccountDataSyncStopper interface so the sync loop is stopped when double puppeting is disabled

Manual testing results

Tested end-to-end with mautrix-whatsapp on Synapse with double puppeting configured. Account data events (m.marked_unread) are correctly received by the sync loop and dispatched to the bridge connector. Loop avoidance works, bridge-originated events are skipped by content comparison, and delayed Synapse re-deliveries (observed up to 3+ minutes late) are also handled correctly.

Test plan

  • Mark a chat as unread from Element -> bridge connector receives the event and forwards to remote network
  • Mark a chat as read from Element (open the chat) -> bridge connector receives read event
  • Bridge sets m.marked_unread via double puppet -> sync echo is skipped (no infinite loop)
  • Disable double puppeting -> account data sync loop stops cleanly
  • Bridge restart -> sync loop resumes when double puppet is re-initialized

Fixes #479
Found while fixing mautrix/whatsapp#891

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

bridgev2: account data events (m.marked_unread, m.tag) from Matrix never reach bridge connectors

1 participant