discord-bridge: relay name falls back to the homeserver (patch 0003) #71
No files matched your search
@@ -431,6 +431,9 @@ channel webhook with their own display name.
|
|||||||
resend, no copy back into Matrix); if not, it retries with the 0001 backoff, checking again before
|
resend, no copy back into Matrix); if not, it retries with the 0001 backoff, checking again before
|
||||||
each resend. A webhook post has no dedupe, so this echo check is what keeps those retries from
|
each resend. A webhook post has no dedupe, so this echo check is what keeps those retries from
|
||||||
double-posting.
|
double-posting.
|
||||||
|
- `0003`: the name and avatar on relayed messages come from the bridge's database copy of room
|
||||||
|
membership. If that read fails (e.g. the database is unreachable) or misses, the bridge now asks
|
||||||
|
Synapse instead of posting under the raw Matrix ID with no avatar (happened 2026-11-23).
|
||||||
|
|
||||||
**Install (one time):** after this repo's `main` has reached `/opt/matrix-config` on LXC 151, run this
|
**Install (one time):** after this repo's `main` has reached `/opt/matrix-config` on LXC 151, run this
|
||||||
on the Proxmox node hosting LXC 109 and 151. It restarts Synapse once and is safe to re-run.
|
on the Proxmox node hosting LXC 109 and 151. It restarts Synapse once and is safe to re-run.
|
||||||
|
|||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
diff --git a/lotus_member.go b/lotus_member.go
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..c9a8e95
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/lotus_member.go
|
||||||
|
@@ -0,0 +1,19 @@
|
||||||
|
+package main
|
||||||
|
+
|
||||||
|
+import (
|
||||||
|
+ "maunium.net/go/mautrix/event"
|
||||||
|
+ "maunium.net/go/mautrix/id"
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
+// lotusMember returns a room member's display name and avatar for relayed
|
||||||
|
+// messages. The bridge normally reads them from its own database copy of room
|
||||||
|
+// state; when that read fails (e.g. the database is unreachable) or the user
|
||||||
|
+// isn't cached yet, it asks the homeserver instead of falling back to the raw
|
||||||
|
+// Matrix ID with no avatar.
|
||||||
|
+func (portal *Portal) lotusMember(userID id.UserID) *event.MemberEventContent {
|
||||||
|
+ member := portal.MainIntent().Member(portal.MXID, userID)
|
||||||
|
+ if member == nil {
|
||||||
|
+ return &event.MemberEventContent{}
|
||||||
|
+ }
|
||||||
|
+ return member
|
||||||
|
+}
|
||||||
|
diff --git a/portal.go b/portal.go
|
||||||
|
index 57ba7f9..17ed1da 100644
|
||||||
|
--- a/portal.go
|
||||||
|
+++ b/portal.go
|
||||||
|
@@ -1450,7 +1450,7 @@ func (br *DiscordBridge) makeMediaProxyURL(mxc id.ContentURI) string {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (portal *Portal) getRelayUserMeta(sender *User) (name, avatarURL string) {
|
||||||
|
- member := portal.bridge.StateStore.GetMember(portal.MXID, sender.MXID)
|
||||||
|
+ member := portal.lotusMember(sender.MXID)
|
||||||
|
name = member.Displayname
|
||||||
|
if name == "" {
|
||||||
|
name = sender.MXID.String()
|
||||||
|
@@ -1502,7 +1502,7 @@ func (portal *Portal) convertReplyMessageToEmbed(eventID id.EventID, url string)
|
||||||
|
targetUser = fmt.Sprintf("<@%s>", puppet.ID)
|
||||||
|
} else if user := portal.bridge.GetUserByMXID(evt.Sender); user != nil && user.DiscordID != "" {
|
||||||
|
targetUser = fmt.Sprintf("<@%s>", user.DiscordID)
|
||||||
|
- } else if member := portal.bridge.StateStore.GetMember(portal.MXID, evt.Sender); member != nil && member.Displayname != "" {
|
||||||
|
+ } else if member := portal.lotusMember(evt.Sender); member.Displayname != "" {
|
||||||
|
targetUser = member.Displayname
|
||||||
|
} else {
|
||||||
|
targetUser = evt.Sender.String()
|
||||||
Reference in new issue
Block a user