Skip to content

bridgev2: relay Matrix messages and reactions through Discord#227

Open
keithah wants to merge 15 commits into
mautrix:megadiscordfrom
keithah:relay-matrix-reactions
Open

bridgev2: relay Matrix messages and reactions through Discord#227
keithah wants to merge 15 commits into
mautrix:megadiscordfrom
keithah:relay-matrix-reactions

Conversation

@keithah

@keithah keithah commented May 30, 2026

Copy link
Copy Markdown

Fix Matrix relay messages in bridgev2 Discord rooms so they are not sent as the relay account.

Relayed Matrix messages now go out through a Discord webhook for the portal. The webhook send uses the Matrix sender's display name, and when possible reuses the matching Discord ghost profile/avatar. It also handles the webhook-specific cases that normal channel sends don't cover: edits/deletes, media uploads, stale webhook recreation, safe allowed mentions, and a small reply fallback embed.

Incoming Discord echoes from the portal's own relay webhook are ignored so Matrix-originated webhook sends are not bridged back as new Discord-originated messages. This matches the old bridge invariant that relay webhook sends are tracked as Matrix-originated messages, not re-imported from the gateway echo.

Relayed Matrix reactions are wired up on the Discord connector side and use the configured relay Discord session as native Discord reactions. Discord does not support per-reaction webhook profile overrides, so reactions must not be represented as webhook messages. bridgev2 only passes relayed reactions to connectors with mautrix/go#510:

mautrix/go#510

Until that lands, the webhook message relay parts of this PR work, but relayed reactions are still blocked in mautrix-go before Discord sees them.

Tested:

  • go test ./pkg/... ./cmd/mautrix-discord
  • deployed on my bridge during development and tested Matrix-to-Discord relay messages, webhook sender profiles, webhook edit/delete behavior, and relayed native reactions

No changelog update included.

Copilot AI review requested due to automatic review settings May 30, 2026 03:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for relaying Matrix reactions via a configured logged-in Discord user session when the reacting Matrix user isn’t logged into Discord.

Changes:

  • Introduces relay_reactions_from config and upgrade support to select a relay Matrix user whose Discord session will be used.
  • Updates reaction handling to fall back to the relay user when a Matrix sender has no Discord session (and webhooks are enabled).
  • Improves redaction handling to remove reactions using the appropriate user session and return clearer status reasons.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
portal.go Adds relay reaction user lookup and uses it for reaction create/remove flows when sender isn’t logged in.
example-config.yaml Documents the new relay_reactions_from configuration option.
config/upgrade.go Copies bridge.relay_reactions_from during config upgrades.
config/bridge.go Adds RelayReactionsFrom to the bridge config struct.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread portal.go Outdated
Comment thread example-config.yaml Outdated
Comment thread portal.go Outdated
Comment thread portal.go Outdated
@keithah keithah force-pushed the relay-matrix-reactions branch from 94c507f to d89c788 Compare July 3, 2026 19:31
@keithah keithah changed the title Relay Matrix reactions through configured Discord session bridgev2: relay Matrix messages and reactions through Discord Jul 3, 2026
@keithah keithah changed the base branch from main to megadiscord July 3, 2026 19:31
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.

2 participants