Correlate own MUC reflections without origin-id (fix Matrix reactions) #5

Merged
skunky merged 2 commits from outgoing-reactions into main 2026-11-08 21:52:45 +00:00
Owner

Problem

Reactions (and replies, edits, read receipts) sent from Matrix to a MUC referenced the bridge invented mx-... id instead of the room-assigned id attribute that remote clients actually see. XMPP clients silently dropped the reactions: the stanza went out, Matrix reported success, nothing appeared on the XMPP side.

The mapping to the room-assigned id was only learned from own reflected MUC messages carrying an origin-id; services that rewrite the id attribute and strip XEP-0359 elements from reflections left the bridge with no mapping at all.

Fix

  • HandleMatrixMessage records outgoing MUC messages in a pending outbox (per room + sender nick, capped, 15 min TTL).
  • Reflected copies without origin-id are correlated with the outbox in noteOwnMUCReflection: identity match, else oldest-first FIFO.
  • Rewritten reflections record the alias, reverse mapping and metadata backfill, so rawIDForOutgoingReference hands out the room-assigned form.
  • Rejected outgoing stanzas (type=error) are logged at warn with error type/condition/text.
  • Includes the previously branch-only commit 6cba0e6 (Matrix reaction removal targeting + hardened outgoing MUC stanzas).

Testing

  • New unit tests: rewritten-id correlation, identity correlation, FIFO ordering, per-nick/room isolation, outbox drain.
  • go test ./... passes, gofmt/go vet clean.
## Problem Reactions (and replies, edits, read receipts) sent from Matrix to a MUC referenced the bridge invented `mx-...` id instead of the room-assigned id attribute that remote clients actually see. XMPP clients silently dropped the reactions: the stanza went out, Matrix reported success, nothing appeared on the XMPP side. The mapping to the room-assigned id was only learned from own reflected MUC messages **carrying an origin-id**; services that rewrite the id attribute and strip XEP-0359 elements from reflections left the bridge with no mapping at all. ## Fix - `HandleMatrixMessage` records outgoing MUC messages in a pending outbox (per room + sender nick, capped, 15 min TTL). - Reflected copies without origin-id are correlated with the outbox in `noteOwnMUCReflection`: identity match, else oldest-first FIFO. - Rewritten reflections record the alias, reverse mapping and metadata backfill, so `rawIDForOutgoingReference` hands out the room-assigned form. - Rejected outgoing stanzas (`type=error`) are logged at warn with error type/condition/text. - Includes the previously branch-only commit `6cba0e6` (Matrix reaction removal targeting + hardened outgoing MUC stanzas). ## Testing - New unit tests: rewritten-id correlation, identity correlation, FIFO ordering, per-nick/room isolation, outbox drain. - `go test ./...` passes, `gofmt`/`go vet` clean.
MUC services that rewrite the id attribute of distributed messages AND
strip XEP-0359 elements from reflections left the bridge with no way to
map a reflected message back to the stored one: reactions, replies,
edits and read receipts bridged from Matrix then referenced the bridge's
invented mx-... id, which no remote client can match, so reactions sent
from Matrix never showed up in XMPP clients.

HandleMatrixMessage now records each outgoing MUC message in a pending
outbox (per room + sender nick, capped, TTL-bound). When a reflected
copy from one of our occupants carries no origin-id,
noteOwnMUCReflection correlates it with the outbox: identity match when
the room kept the id attribute, FIFO otherwise. Rewritten reflections
record the alias, the reverse mapping and the message metadata backfill,
so rawIDForOutgoingReference hands out the room-assigned form.
Log rejected outgoing message stanzas with error details
Some checks failed
CI / test (pull_request) Has been cancelled
5467f06323
A MUC service rejecting an outgoing stanza (message, reaction, edit,
receipt, ...) only reports back through a type='error' message stanza,
which was previously reduced to a from-only debug line. Log the error
type, condition and text at warn level so silent MUC rejections become
diagnosable.
skunky merged commit 59f5c84b2d into main 2026-11-08 21:52:45 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
xmpp-bridge/mautrix-xmpp!5
No description provided.