Media, avatars, direct media; fix reactions/replies; MUC typing #1

Merged
skunky merged 3 commits from skunky/media-avatars-reactions-typing into main 2026-11-08 18:58:29 +00:00 AGit
Owner

Fix Matrix->XMPP media (unsupported format), add direct media both ways, avatars both directions (vCard/PEP), fix reaction/reply target resolution (MUC-rewritten ids + stanza-id priority) and bridge MUC typing to Matrix.

Fix Matrix->XMPP media (unsupported format), add direct media both ways, avatars both directions (vCard/PEP), fix reaction/reply target resolution (MUC-rewritten ids + stanza-id priority) and bridge MUC typing to Matrix.
Matrix -> XMPP media was rejected with "unsupported message type" for
every image, video, audio and file: the connector's RoomFeatures
declared no File capability map at all, so bridgev2's
checkMessageContentCaps dropped everything before the connector ever
saw the event. Declare the full media capability set (image, video,
audio, file, voice, gif, sticker) with wildcard MIME support, captions
and the configured size cap, and version the capability IDs.

Rework the outgoing media chain in the same pass:

- When media.direct_media is enabled, Matrix media is shared with XMPP
  users as a signed public URL served by the bridge
  (MatrixConnectorWithPublicMedia.GetPublicMediaAddressForEvent)
  instead of being re-uploaded via XEP-0363; HTTP upload remains the
  fallback and is still used when public media is not configured.
- When XEP-0363 fails or is disabled, fall back to the signed public
  URL instead of putting a useless mxc URI into the message body.
- HandleMatrixMessage keeps the OOB payload and body semantics for
  captions.

Add direct media for the XMPP -> Matrix direction by implementing
bridgev2.DirectMediableNetwork: when the Matrix connector enables
direct media, incoming XMPP media is exposed as an mxc URI backed by
the bridge's own media server. The media ID encodes the XEP-0363
source URL, and downloads are answered with a redirect to it, so media
bytes flow straight from the XMPP server to the Matrix client without
a copy on the homeserver. A cheap HEAD request sniffs the MIME type for
inline rendering.

Also fix the reupload_to_matrix=false path, which stuffed a plain HTTPS
URL into content.URL (Matrix clients can only fetch mxc URIs); such
links are now sent as text messages with a proper HTML anchor.
XMPP -> Matrix:
- Fetch ghost avatars from XEP-0084 (PEP user avatar) with a XEP-0054
  vCard photo fallback, deduplicated through an in-memory cache keyed
  by photo hash; failed lookups are retried only after a TTL so users
  without avatars do not generate per-message IQs.
- Skip profile lookups for the bridge's own bot and puppet JIDs in
  component mode (querying them would hit the bridge itself).
- Expose MUC room vCard photos as the portal room avatar (adopted rooms
  keep their existing behavior of preserving Matrix-side identity).

Matrix -> XMPP (component mode):
- New vCard responder: the component answers XEP-0054 vCard queries for
  its own bot JID and every puppet JID, returning the Matrix display
  name and avatar (downloaded via the bot intent, base64 BINVAL).
- Puppet profiles are resolved from the portal member lists (the same
  source the puppet nicks come from) and cached for an hour; the bot
  vCard carries the bridge display name.
- Advertise photo hashes via XEP-0153 vcard-temp❌update presence
  after puppet joins/rejoins and announce the bot's empty photo, so
  clients re-fetch vCards when avatars change.
- Advertise vcard-temp and vcard-update in disco#info.

In client mode Matrix -> XMPP avatars are intentionally not available:
the XMPP server owns account vCards and the bridge cannot speak for
other users.
Reactions (XEP-0444), replies (XEP-0461) and read markers from XMPP
clients failed with "Target message for reaction not found" whenever
the referenced id attribute was not the stored form:

* The MUC service rewrites the id attribute of distributed messages,
  so the room-assigned IDs of our own reflected messages never existed
  in the message table. The roomIDCache existed for this but was dead
  code: rememberRoomID was never called. Own reflected messages (bot
  and puppet nicks) now record the mapping both in memory and durably
  in kv_store (xmpp/roomid/<room>/<id>), and resolveMessageID consults
  the cache and the KV mapping as fallbacks.
* computeIncomingMessageID preferred the server-assigned stanza-id over
  the id attribute, but user-facing payloads (reactions, replies,
  markers) always reference the id attribute. The id attribute is now
  preferred over the stanza-id (origin-id stays first, so dedup of our
  own messages is unaffected).

Also bridge XEP-0085 chat states from MUC occupants: composing/active/
inactive/gone now map to Matrix typing start/stop in the portal, which
was previously dropped entirely (only DMs had typing support).

Note: full XMPP presence (show/status) sync is still not implemented;
bridgev2 has no remote presence event type yet.
skunky merged commit 08c1b427d0 into main 2026-11-08 18:58:29 +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!1
No description provided.