discord-bridge: relay name falls back to the homeserver (patch 0003) #71

Merged
jared merged 1 commits from discord-bridge/relay-name-fallback into main 2026-11-23 11:39:00 -05:00
Owner

What happened (2026-11-23): Postgres lost the bridge's pg_hba rule (pve-infra#17 fixes the cause). The bridge kept running without database access. At 10:28 a relayed message went to Discord as @jared:matrix.lotusguild.org with no avatar, instead of the sender's display name and picture. The bridge then crashed when it tried to save the message record.

Why: getRelayUserMeta read the sender's display name and avatar only from the bridge's DB copy of room membership (StateStore.GetMember). When that read failed, it fell back to the raw Matrix ID with no avatar.

Fix: patch 0003 reads members through IntentAPI.Member. That uses the same cache, but asks Synapse for the member event when the cached read fails or misses. The reply-embed name uses it too. In normal operation nothing changes: the cache hits and no extra request is made.

Testing:

  • go vet is clean.
  • Built with build-patched.sh; patches 0001–0003 apply cleanly to v0.7.7, and the existing Retry/Echo tests pass.
  • Deployed to LXC 151 at 11:32. The bridge started and connected to Discord.
  • Backup of the previous binary: /opt/mautrix-discord/mautrix-discord.bak-20261123-patch0002.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

**What happened (2026-11-23):** Postgres lost the bridge's pg_hba rule (pve-infra#17 fixes the cause). The bridge kept running without database access. At 10:28 a relayed message went to Discord as `@jared:matrix.lotusguild.org` with no avatar, instead of the sender's display name and picture. The bridge then crashed when it tried to save the message record. **Why:** `getRelayUserMeta` read the sender's display name and avatar only from the bridge's DB copy of room membership (`StateStore.GetMember`). When that read failed, it fell back to the raw Matrix ID with no avatar. **Fix:** patch `0003` reads members through `IntentAPI.Member`. That uses the same cache, but asks Synapse for the member event when the cached read fails or misses. The reply-embed name uses it too. In normal operation nothing changes: the cache hits and no extra request is made. **Testing:** - `go vet` is clean. - Built with `build-patched.sh`; patches 0001–0003 apply cleanly to v0.7.7, and the existing Retry/Echo tests pass. - Deployed to LXC 151 at 11:32. The bridge started and connected to Discord. - Backup of the previous binary: `/opt/mautrix-discord/mautrix-discord.bak-20261123-patch0002`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared added 1 commit 2026-11-23 11:33:02 -05:00
discord-bridge: relay name falls back to the homeserver (patch 0003)
Lint / Shell (shellcheck) (push) Successful in 12s
Lint / Landing page is rendered (matrix (push) Successful in 6s
Lint / No secrets in webhook configs (push) Successful in 9s
Lint / Python (ruff) (push) Successful in 14s
Lint / Secret scan (gitleaks) (push) Successful in 13s
Lint / Shell (shellcheck) (pull_request) Successful in 17s
Lint / Python deps (pip-audit) (push) Successful in 51s
Lint / No Hookshot webhook IDs in README (pull_request) Successful in 7s
Lint / No secrets in webhook configs (pull_request) Successful in 8s
Lint / Python (ruff) (pull_request) Successful in 7s
Lint / Landing page is rendered (matrix (pull_request) Successful in 8s
Lint / Secret scan (gitleaks) (pull_request) Successful in 10s
Lint / JS (eslint) (push) Successful in 12s
Lint / No Hookshot webhook IDs in README (push) Successful in 12s
Lint / Python deps (pip-audit) (pull_request) Successful in 56s
Lint / JS (eslint) (pull_request) Successful in 11s
a4a0b0bd0d
On 2026-11-23 the bridge lost database access (pg_hba rule wiped by a
pve-infra deploy) but kept running. A relayed message then went to Discord
as "@jared:matrix.lotusguild.org" with no avatar, because the sender's
display name/avatar come only from the bridge's DB copy of room state and
that read failed.

Patch 0003 reads members through IntentAPI.Member, which uses the same
cache but asks Synapse when the cached read fails or misses. Also used for
the name in reply embeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared scheduled this pull request to auto merge when all checks succeed 2026-11-23 11:36:57 -05:00
jared merged commit c7ef863530 into main 2026-11-23 11:39:00 -05:00
jared deleted branch discord-bridge/relay-name-fallback 2026-11-23 11:39:19 -05:00
Sign in to join this conversation.