From 44d6e64f0844fb709d33c039b12e05f5b6491ecd Mon Sep 17 00:00:00 2001 From: Swirly Date: Fri, 19 Jun 2026 19:35:22 -0500 Subject: [PATCH 01/31] implement MSC4144 --- bridge/config/config.go | 1 + bridge/matrix/matrix.go | 347 ++++++++++++++++++++++++------ changelog.md | 2 + docs/protocols/matrix/settings.md | 11 + matterbridge.toml.sample | 5 + 5 files changed, 295 insertions(+), 71 deletions(-) diff --git a/bridge/config/config.go b/bridge/config/config.go index 4c042a5a8f..c2af77bb58 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -216,6 +216,7 @@ type Protocol struct { UseFirstName bool // telegram UseUserName bool // discord, matrix, mattermost UseInsecureURL bool // telegram + UseMSC4144 bool // matrix UserName string // IRC VerboseJoinPart bool // IRC WebhookBindAddress string // mattermost, slack diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index a4cd7d4189..924929ca57 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -212,11 +212,32 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { // Make a action /me of the message if msg.Event == config.EventUserAction { - content := event.MessageEventContent{ - MsgType: event.MsgEmote, - Body: body, - FormattedBody: formattedBody, - Format: event.FormatHTML, + var content event.MessageEventContent + if b.GetBool("UseMSC4144") { + body, _ = strings.CutPrefix(body, username.plain) + body = username.plain + ": " + body + formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) + formattedBody = "" + username.plain + ": " + formattedBody + content = event.MessageEventContent{ + MsgType: event.MsgEmote, + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + content.AddPerMessageProfileFallback() + } else { + content = event.MessageEventContent{ + MsgType: event.MsgEmote, + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + } } if b.GetBool("HTMLDisable") { @@ -283,21 +304,52 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { // Edit message if we have an ID if msg.ID != "" { - content := event.MessageEventContent{ - Body: "* " + body, - FormattedBody: "* " + formattedBody, - MsgType: event.MsgText, - Format: event.FormatHTML, - NewContent: &event.MessageEventContent{ - Body: body, - FormattedBody: formattedBody, + var content event.MessageEventContent + if b.GetBool("UseMSC4144") { + body, _ = strings.CutPrefix(body, username.plain) + body = username.plain + ": " + body + formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) + formattedBody = "" + username.plain + ": " + formattedBody + content = event.MessageEventContent{ + Body: "* " + body, + FormattedBody: "* " + formattedBody, + MsgType: event.MsgText, Format: event.FormatHTML, + NewContent: &event.MessageEventContent{ + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + MsgType: event.MsgText, + }, + RelatesTo: &event.RelatesTo{ + EventID: id.EventID(msg.ID), + Type: event.RelReplace, + }, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + content.AddPerMessageProfileFallback() + } else { + content = event.MessageEventContent{ + Body: "* " + body, + FormattedBody: "* " + formattedBody, MsgType: event.MsgText, - }, - RelatesTo: &event.RelatesTo{ - EventID: id.EventID(msg.ID), - Type: event.RelReplace, - }, + Format: event.FormatHTML, + NewContent: &event.MessageEventContent{ + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + MsgType: event.MsgText, + }, + RelatesTo: &event.RelatesTo{ + EventID: id.EventID(msg.ID), + Type: event.RelReplace, + }, + } } if b.GetBool("HTMLDisable") { @@ -352,19 +404,89 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { // Reply to parent if message has a parent id if msg.ParentValid() { + var content event.MessageEventContent + if b.GetBool("UseMSC4144") { + body, _ = strings.CutPrefix(body, username.plain) + body = username.plain + ": " + body + formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) + formattedBody = "" + username.plain + ": " + formattedBody + + content = event.MessageEventContent{ + MsgType: event.MsgText, + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + RelatesTo: &event.RelatesTo{ + Type: "m.reply", + InReplyTo: &event.InReplyTo{ + EventID: id.EventID(msg.ParentID), + }, + }, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + content.AddPerMessageProfileFallback() + } else { + content = event.MessageEventContent{ + MsgType: event.MsgText, + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + RelatesTo: &event.RelatesTo{ + Type: "m.reply", + InReplyTo: &event.InReplyTo{ + EventID: id.EventID(msg.ParentID), + }, + }, + } + } + + if b.GetBool("HTMLDisable") { + content.Format = "" + content.FormattedBody = "" + } + + var ( + resp *mautrix.RespSendEvent + err error + ) + + err = b.retry(func() error { + resp, err = b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) + + return err + }) + if err != nil { + return "", err + } + + return resp.EventID.String(), err + } + + if b.GetBool("UseMSC4144") { + body, _ = strings.CutPrefix(body, username.plain) + body = username.plain + ": " + body + formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) + formattedBody = "" + username.plain + ": " + formattedBody + content := event.MessageEventContent{ MsgType: event.MsgText, Body: body, FormattedBody: formattedBody, Format: event.FormatHTML, - RelatesTo: &event.RelatesTo{ - Type: "m.reply", - InReplyTo: &event.InReplyTo{ - EventID: id.EventID(msg.ParentID), - }, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, }, } + content.AddPerMessageProfileFallback() + if b.GetBool("HTMLDisable") { content.Format = "" content.FormattedBody = "" @@ -386,7 +508,6 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { return resp.EventID.String(), err } - // Send a normal message msgID, err := b.sendNormalMessage(roomID, body, formattedBody) if err != nil { @@ -845,27 +966,29 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co sp := strings.Split(fi.Name, ".") mtype := mime.TypeByExtension("." + sp[len(sp)-1]) // image and video uploads send no username, we have to do this ourself here #715 - err := b.retry(func() error { - content := event.MessageEventContent{ - MsgType: event.MsgText, - Body: username.plain + fi.Comment, - FormattedBody: username.formatted + fi.Comment, - Format: event.FormatHTML, - } + if !b.GetBool("UseMSC4144") { + err := b.retry(func() error { + content := event.MessageEventContent{ + MsgType: event.MsgText, + Body: username.plain + fi.Comment, + FormattedBody: username.formatted + fi.Comment, + Format: event.FormatHTML, + } - _, err2 := b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) + _, err2 := b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) - return err2 - }) - if err != nil { - b.Log.Errorf("file comment failed: %#v", err) + return err2 + }) + if err != nil { + b.Log.Errorf("file comment failed: %#v", err) + } } b.Log.Debugf("uploading file: %s %s", fi.Name, mtype) var res *mautrix.RespMediaUpload - err = b.retry(func() error { + err := b.retry(func() error { media := mautrix.ReqUploadMedia{ Content: content, ContentType: mtype, @@ -888,14 +1011,34 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co case strings.Contains(mtype, "video"): b.Log.Debugf("sendVideo %s", res.ContentURI) err = b.retry(func() error { - content := event.MessageEventContent{ - MsgType: event.MsgVideo, - FileName: fi.Name, - URL: id.ContentURIString(res.ContentURI.String()), - Info: &event.FileInfo{ - MimeType: mtype, - Size: len(*fi.Data), - }, + var content event.MessageEventContent + if b.GetBool("UseMSC4144") { + content = event.MessageEventContent{ + MsgType: event.MsgVideo, + FileName: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + }, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + content.AddPerMessageProfileFallback() + } else { + content = event.MessageEventContent{ + MsgType: event.MsgVideo, + FileName: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + }, + } } _, err2 := b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) @@ -916,16 +1059,38 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("Image format detected: %s (%dx%d)", format, cfg.Width, cfg.Height) - img := event.MessageEventContent{ - MsgType: event.MsgImage, - Body: fi.Name, - URL: id.ContentURIString(res.ContentURI.String()), - Info: &event.FileInfo{ - MimeType: mtype, - Size: len(*fi.Data), - Width: cfg.Width, // #nosec G115 -- go std will not returned negative size - Height: cfg.Height, // #nosec G115 -- go std will not returned negative size - }, + var img event.MessageEventContent + if b.GetBool("UseMSC4144") { + img = event.MessageEventContent{ + MsgType: event.MsgImage, + Body: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + Width: cfg.Width, // #nosec G115 -- go std will not returned negative size + Height: cfg.Height, // #nosec G115 -- go std will not returned negative size + }, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + img.AddPerMessageProfileFallback() + } else { + img = event.MessageEventContent{ + MsgType: event.MsgImage, + Body: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + Width: cfg.Width, // #nosec G115 -- go std will not returned negative size + Height: cfg.Height, // #nosec G115 -- go std will not returned negative size + }, + } } err = b.retry(func() error { @@ -945,14 +1110,34 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co }(): b.Log.Debugf("sendAudio %s", res.ContentURI) err = b.retry(func() error { - content := event.MessageEventContent{ - MsgType: event.MsgAudio, - FileName: fi.Name, - URL: id.ContentURIString(res.ContentURI.String()), - Info: &event.FileInfo{ - MimeType: mtype, - Size: len(*fi.Data), - }, + var content event.MessageEventContent + if b.GetBool("UseMSC4144") { + content = event.MessageEventContent{ + MsgType: event.MsgAudio, + FileName: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + }, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + content.AddPerMessageProfileFallback() + } else { + content = event.MessageEventContent{ + MsgType: event.MsgAudio, + FileName: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + }, + } } _, err2 := b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) return err2 @@ -963,14 +1148,34 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co default: b.Log.Debugf("sendFile %s", res.ContentURI) err = b.retry(func() error { - content := event.MessageEventContent{ - MsgType: event.MsgFile, - FileName: fi.Name, - URL: id.ContentURIString(res.ContentURI.String()), - Info: &event.FileInfo{ - MimeType: mtype, - Size: len(*fi.Data), - }, + var content event.MessageEventContent + if b.GetBool("UseMSC4144") { + content = event.MessageEventContent{ + MsgType: event.MsgFile, + FileName: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + }, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + content.AddPerMessageProfileFallback() + } else { + content = event.MessageEventContent{ + MsgType: event.MsgFile, + FileName: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), + Info: &event.FileInfo{ + MimeType: mtype, + Size: len(*fi.Data), + }, + } } _, err2 := b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) diff --git a/changelog.md b/changelog.md index f3e24eed51..a1a518112f 100644 --- a/changelog.md +++ b/changelog.md @@ -32,6 +32,8 @@ - matterbridge is now built with whatsappmulti backend enabled by default, unless the `nowhatsappmulti` build tag is passed - Docker images are now automatically built and published to `ghcr.io/matterbridge-org/matterbridge` ([#86](https://github.com/matterbridge-org/matterbridge/pull/86)) - matterbridge will now apply a default `RemoteNickFormat` setting of `"[{PROTOCOL}] <{NICK}> "` which may be overridden by individual bridge settings, environment variables, or the `General` section of the config file, fulfilling the enhancement requested at ([#162](https://github.com/matterbridge-org/matterbridge/issues/162)) +- matrix + - Supports MSC4144/puppeting ([#232](https://github.com/matterbridge-org/matterbridge/pulls/232)). See also [MSC4144](https://github.com/matrix-org/matrix-spec-proposals/pulls/4144). - mastodon - Add new Mastodon bridge ([#14](https://github.com/matterbridge-org/matterbridge/pull/14)/[#16](https://github.com/matterbridge-org/matterbridge/pull/16), thanks @lil5) - Supports public messages and private messages diff --git a/docs/protocols/matrix/settings.md b/docs/protocols/matrix/settings.md index 9c273721f3..4bbeddcf8c 100644 --- a/docs/protocols/matrix/settings.md +++ b/docs/protocols/matrix/settings.md @@ -137,3 +137,14 @@ Shows the username instead of the displayname ```toml UseUserName=true ``` + +## UseMSC4144 + +Use MSC4144 to set nick per-message. See https://github.com/matrix-org/matrix-spec-proposals/pull/4144. + +- Setting: **OPTIONAL**, **RELOADABLE** +- Format: *boolean* +- Example: + ```toml + UseMSC4144=true + ``` diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index be060de446..3cf47e1b69 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1371,6 +1371,11 @@ ShowJoinPart=false #OPTIONAL (default false) SpoofUsername=false +#Use MSC4144 to set nick per-message, like IRC RELAYMSG. See https://github.com/matrix-org/matrix-spec-proposals/pull/4144 +#This has less support scross clients but makes less API requests compared to SpoofUsername +#OPTIONAL (default false) +UseMSC4144=false + #StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 #It will strip other characters from the nick #OPTIONAL (default false) From f6883306466636f255dd34851bac38505a3e7edf Mon Sep 17 00:00:00 2001 From: Swirly Date: Sat, 20 Jun 2026 08:11:16 -0500 Subject: [PATCH 02/31] missed a spot --- bridge/matrix/matrix.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 924929ca57..415bc7b154 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -966,7 +966,28 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co sp := strings.Split(fi.Name, ".") mtype := mime.TypeByExtension("." + sp[len(sp)-1]) // image and video uploads send no username, we have to do this ourself here #715 - if !b.GetBool("UseMSC4144") { + if b.GetBool("UseMSC4144") { + err := b.retry(func() error { + content := event.MessageEventContent{ + MsgType: event.MsgText, + Body: username.plain + ": " + fi.Comment, + FormattedBody: "" + username.plain + ": " + fi.Comment, + Format: event.FormatHTML, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + + _, err2 := b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) + + return err2 + }) + if err != nil { + b.Log.Errorf("file comment failed: %#v", err) + } + } else { err := b.retry(func() error { content := event.MessageEventContent{ MsgType: event.MsgText, From 1da77931caa70eed5982d6d48c9511c3c6e67b3d Mon Sep 17 00:00:00 2001 From: Swirly Date: Sat, 20 Jun 2026 10:22:09 -0500 Subject: [PATCH 03/31] Update changelog.md --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index a1a518112f..d5f6d7d229 100644 --- a/changelog.md +++ b/changelog.md @@ -33,7 +33,7 @@ - Docker images are now automatically built and published to `ghcr.io/matterbridge-org/matterbridge` ([#86](https://github.com/matterbridge-org/matterbridge/pull/86)) - matterbridge will now apply a default `RemoteNickFormat` setting of `"[{PROTOCOL}] <{NICK}> "` which may be overridden by individual bridge settings, environment variables, or the `General` section of the config file, fulfilling the enhancement requested at ([#162](https://github.com/matterbridge-org/matterbridge/issues/162)) - matrix - - Supports MSC4144/puppeting ([#232](https://github.com/matterbridge-org/matterbridge/pulls/232)). See also [MSC4144](https://github.com/matrix-org/matrix-spec-proposals/pulls/4144). + - Supports MSC4144/puppeting ([#232](https://github.com/matterbridge-org/matterbridge/pulls/232)). See also [MSC4144](https://github.com/matrix-org/matrix-spec-proposals/pulls/4144). Note that this is useless unless you have a client that can display these. Clients that don't will fall back to displaying e.g. `Nick: msg`. - mastodon - Add new Mastodon bridge ([#14](https://github.com/matterbridge-org/matterbridge/pull/14)/[#16](https://github.com/matterbridge-org/matterbridge/pull/16), thanks @lil5) - Supports public messages and private messages From 85b6e4230a4d5e895dd7ac96084baac19951a333 Mon Sep 17 00:00:00 2001 From: Swirly Date: Sat, 20 Jun 2026 10:25:46 -0500 Subject: [PATCH 04/31] Update matterbridge.toml.sample --- matterbridge.toml.sample | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 3cf47e1b69..ad080f7dd8 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1372,7 +1372,8 @@ ShowJoinPart=false SpoofUsername=false #Use MSC4144 to set nick per-message, like IRC RELAYMSG. See https://github.com/matrix-org/matrix-spec-proposals/pull/4144 -#This has less support scross clients but makes less API requests compared to SpoofUsername +#This has less support scross clients but makes less API requests compared to SpoofUsername. +#Clients that don't support this will display e.g. Nick: msg, with the nick in bold #OPTIONAL (default false) UseMSC4144=false From 20d8d811fb65e9ee26eb76f70fd28d4854b0aa68 Mon Sep 17 00:00:00 2001 From: Swirly Date: Sat, 20 Jun 2026 10:28:09 -0500 Subject: [PATCH 05/31] Update settings.md --- docs/protocols/matrix/settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/protocols/matrix/settings.md b/docs/protocols/matrix/settings.md index 4bbeddcf8c..f89eed6fd9 100644 --- a/docs/protocols/matrix/settings.md +++ b/docs/protocols/matrix/settings.md @@ -140,7 +140,7 @@ Shows the username instead of the displayname ## UseMSC4144 -Use MSC4144 to set nick per-message. See https://github.com/matrix-org/matrix-spec-proposals/pull/4144. +Use MSC4144 to set nick per-message. See https://github.com/matrix-org/matrix-spec-proposals/pull/4144. At the moment this is an open proposal and is subject to change. Clients that don't support this will display e.g. `Nick: msg` with the nick in bold. - Setting: **OPTIONAL**, **RELOADABLE** - Format: *boolean* From 9b60e497c4727fe415c3fbbe9a733a949af0e802 Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 20:47:31 -0500 Subject: [PATCH 06/31] Revert "missed a spot" This reverts commit f6883306466636f255dd34851bac38505a3e7edf. --- bridge/matrix/matrix.go | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 415bc7b154..924929ca57 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -966,28 +966,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co sp := strings.Split(fi.Name, ".") mtype := mime.TypeByExtension("." + sp[len(sp)-1]) // image and video uploads send no username, we have to do this ourself here #715 - if b.GetBool("UseMSC4144") { - err := b.retry(func() error { - content := event.MessageEventContent{ - MsgType: event.MsgText, - Body: username.plain + ": " + fi.Comment, - FormattedBody: "" + username.plain + ": " + fi.Comment, - Format: event.FormatHTML, - BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, - Displayname: username.plain, - HasFallback: true, - }, - } - - _, err2 := b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) - - return err2 - }) - if err != nil { - b.Log.Errorf("file comment failed: %#v", err) - } - } else { + if !b.GetBool("UseMSC4144") { err := b.retry(func() error { content := event.MessageEventContent{ MsgType: event.MsgText, From e853038cf7ae742bd0700cb6d28688720c2c6519 Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:03:33 -0500 Subject: [PATCH 07/31] missed a spot 2: electric boogaloo --- bridge/matrix/matrix.go | 49 +++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 924929ca57..fed99f0d92 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1206,8 +1206,24 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string) (str ) err = b.retry(func() error { - resp, err = b.mc.SendText(context.TODO(), roomID, body) - + if b.GetBool("UseMSC4144") { + body, _ = strings.CutPrefix(body, username.plain) + body = username.plain + ": " + body + formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) + formattedBody = "" + username.plain + ": " + formattedBody + content := event.MessageEventContent{ + MsgType: event.MsgText, + Body: body, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + resp, err = b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) + } else { + resp, err = b.mc.SendText(context.TODO(), roomID, body) + } return err }) if err != nil { @@ -1224,11 +1240,30 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted ) err = b.retry(func() error { - content := event.MessageEventContent{ - MsgType: event.MsgText, - Body: body, - FormattedBody: formattedBody, - Format: event.FormatHTML, + var content event.MessageEventContent + if b.GetBool("UseMSC4144") { + body, _ = strings.CutPrefix(body, username.plain) + body = username.plain + ": " + body + formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) + formattedBody = "" + username.plain + ": " + formattedBody + content = event.MessageEventContent{ + MsgType: event.MsgText, + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, + } + } else { + content = event.MessageEventContent{ + MsgType: event.MsgText, + Body: body, + FormattedBody: formattedBody, + Format: event.FormatHTML, + } } resp, err = b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) From a6554f1f703608360bf9f125f100290d5d2f37e7 Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:07:24 -0500 Subject: [PATCH 08/31] all hail gofmt --- bridge/matrix/matrix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index fed99f0d92..36c996fc4c 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1220,7 +1220,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string) (str HasFallback: true, }, } - resp, err = b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) + resp, err = b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) } else { resp, err = b.mc.SendText(context.TODO(), roomID, body) } From c459ab7d592ba8f059b11b555ae5f3963cf071da Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:43:40 -0500 Subject: [PATCH 09/31] but lets go back --- bridge/matrix/matrix.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 36c996fc4c..d95d493ea9 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -509,7 +509,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { return resp.EventID.String(), err } // Send a normal message - msgID, err := b.sendNormalMessage(roomID, body, formattedBody) + msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, msg) if err != nil { return "", err } @@ -1189,17 +1189,17 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("result: %#v", res) } -func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string) (string, error) { +func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username string, msg config.Message) (string, error) { if b.GetBool("HTMLDisable") { // Send a plain text message if html is disabled - return b.sendNormalMessagePlaintext(roomID, body) + return b.sendNormalMessagePlaintext(roomID, body, username, msg) } else { // Post normal message with HTML support (eg riot.im) - return b.sendNormalMessageHTML(roomID, body, formattedBody) + return b.sendNormalMessageHTML(roomID, body, formattedBody, username, msg) } } -func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string) (string, error) { +func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username string, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error @@ -1233,7 +1233,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string) (str return resp.EventID.String(), err } -func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string) (string, error) { +func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username string, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error From b352ea24ef42a0f5a53fdd7138050d746aa4ad6c Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:46:54 -0500 Subject: [PATCH 10/31] oops --- bridge/matrix/matrix.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index d95d493ea9..be116703e3 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1189,7 +1189,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("result: %#v", res) } -func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username string, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { if b.GetBool("HTMLDisable") { // Send a plain text message if html is disabled return b.sendNormalMessagePlaintext(roomID, body, username, msg) @@ -1199,7 +1199,7 @@ func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody } } -func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username string, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error @@ -1233,7 +1233,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user return resp.EventID.String(), err } -func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username string, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error From 5e5671f1680c3e38f6ee400381afc6ed256dabc9 Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:47:45 -0500 Subject: [PATCH 11/31] wait --- bridge/matrix/matrix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index be116703e3..7cc8d55897 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -941,7 +941,7 @@ func (b *Bmatrix) handleUploadFiles(msg *config.Message, roomID id.RoomID) (stri formattedBody := username.formatted + helper.ParseMarkdown(msg.Text) // TODO: message ID - _, err := b.sendNormalMessage(roomID, body, formattedBody) + _, err := b.endNormalMessage(roomID, body, formattedBody, username, msg) if err != nil { // Assume if there was an error sending a simple text message, // sending the attachments will not be possible. From afcf15bb6fcbbd469052adc39c555b6fb9aa0eb5 Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:49:24 -0500 Subject: [PATCH 12/31] please? --- bridge/matrix/matrix.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 7cc8d55897..f0b96f406e 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -941,7 +941,7 @@ func (b *Bmatrix) handleUploadFiles(msg *config.Message, roomID id.RoomID) (stri formattedBody := username.formatted + helper.ParseMarkdown(msg.Text) // TODO: message ID - _, err := b.endNormalMessage(roomID, body, formattedBody, username, msg) + _, err := b.sendNormalMessage(roomID, body, formattedBody, username, msg) if err != nil { // Assume if there was an error sending a simple text message, // sending the attachments will not be possible. @@ -1209,8 +1209,6 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user if b.GetBool("UseMSC4144") { body, _ = strings.CutPrefix(body, username.plain) body = username.plain + ": " + body - formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) - formattedBody = "" + username.plain + ": " + formattedBody content := event.MessageEventContent{ MsgType: event.MsgText, Body: body, From 96bf8bdb27f7696927588054c15cf5d86942d80a Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:50:27 -0500 Subject: [PATCH 13/31] come on you can do it --- bridge/matrix/matrix.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index f0b96f406e..fe4e2e8d1e 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1189,7 +1189,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("result: %#v", res) } -func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { if b.GetBool("HTMLDisable") { // Send a plain text message if html is disabled return b.sendNormalMessagePlaintext(roomID, body, username, msg) @@ -1199,7 +1199,7 @@ func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody } } -func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg *config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error @@ -1231,7 +1231,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user return resp.EventID.String(), err } -func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error From a90959ae49943d4803e2edc015a26f5573964484 Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:51:52 -0500 Subject: [PATCH 14/31] a --- bridge/matrix/matrix.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index fe4e2e8d1e..f0b96f406e 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1189,7 +1189,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("result: %#v", res) } -func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { if b.GetBool("HTMLDisable") { // Send a plain text message if html is disabled return b.sendNormalMessagePlaintext(roomID, body, username, msg) @@ -1199,7 +1199,7 @@ func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody } } -func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg *config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error @@ -1231,7 +1231,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user return resp.EventID.String(), err } -func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error From 6ae1fac7b38652b42c6dc24cf13fb37151075b3d Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:54:09 -0500 Subject: [PATCH 15/31] yea? --- bridge/matrix/matrix.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index f0b96f406e..179dbbc986 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -509,7 +509,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { return resp.EventID.String(), err } // Send a normal message - msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, msg) + msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, *config.Message(msg)) if err != nil { return "", err } @@ -1189,7 +1189,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("result: %#v", res) } -func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { if b.GetBool("HTMLDisable") { // Send a plain text message if html is disabled return b.sendNormalMessagePlaintext(roomID, body, username, msg) @@ -1199,7 +1199,7 @@ func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody } } -func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg *config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error @@ -1231,7 +1231,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user return resp.EventID.String(), err } -func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error From 3734f2165f4535b1e78d339b9fdb4fdf666c261d Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:55:10 -0500 Subject: [PATCH 16/31] maybe? --- bridge/matrix/matrix.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 179dbbc986..46df60f0ae 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -509,7 +509,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { return resp.EventID.String(), err } // Send a normal message - msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, *config.Message(msg)) + msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, config.Message(msg)) if err != nil { return "", err } @@ -1189,7 +1189,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("result: %#v", res) } -func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { if b.GetBool("HTMLDisable") { // Send a plain text message if html is disabled return b.sendNormalMessagePlaintext(roomID, body, username, msg) @@ -1199,7 +1199,7 @@ func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody } } -func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg *config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error @@ -1231,7 +1231,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user return resp.EventID.String(), err } -func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error From 49df682fcfb8178eb5376ba714fbaf4c067bcf3a Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:56:26 -0500 Subject: [PATCH 17/31] im tired, boss --- bridge/matrix/matrix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 46df60f0ae..f02b144c6c 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -941,7 +941,7 @@ func (b *Bmatrix) handleUploadFiles(msg *config.Message, roomID id.RoomID) (stri formattedBody := username.formatted + helper.ParseMarkdown(msg.Text) // TODO: message ID - _, err := b.sendNormalMessage(roomID, body, formattedBody, username, msg) + _, err := b.sendNormalMessage(roomID, body, formattedBody, username, config.Message(msg)) if err != nil { // Assume if there was an error sending a simple text message, // sending the attachments will not be possible. From e08286ab3c48b60819611d97ba5e5116b3d73afe Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sat, 20 Jun 2026 21:57:58 -0500 Subject: [PATCH 18/31] its late... please... --- bridge/matrix/matrix.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index f02b144c6c..43c69bc7db 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -509,7 +509,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { return resp.EventID.String(), err } // Send a normal message - msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, config.Message(msg)) + msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, *msg) if err != nil { return "", err } @@ -941,7 +941,7 @@ func (b *Bmatrix) handleUploadFiles(msg *config.Message, roomID id.RoomID) (stri formattedBody := username.formatted + helper.ParseMarkdown(msg.Text) // TODO: message ID - _, err := b.sendNormalMessage(roomID, body, formattedBody, username, config.Message(msg)) + _, err := b.sendNormalMessage(roomID, body, formattedBody, username, msg) if err != nil { // Assume if there was an error sending a simple text message, // sending the attachments will not be possible. @@ -1189,7 +1189,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co b.Log.Debugf("result: %#v", res) } -func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { if b.GetBool("HTMLDisable") { // Send a plain text message if html is disabled return b.sendNormalMessagePlaintext(roomID, body, username, msg) @@ -1199,7 +1199,7 @@ func (b *Bmatrix) sendNormalMessage(roomID id.RoomID, body string, formattedBody } } -func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, username *matrixUsername, msg *config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error @@ -1231,7 +1231,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user return resp.EventID.String(), err } -func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg config.Message) (string, error) { +func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formattedBody string, username *matrixUsername, msg *config.Message) (string, error) { var ( resp *mautrix.RespSendEvent err error From dcda35d78e250ab60df2f1c3f5488289a4c24b85 Mon Sep 17 00:00:00 2001 From: Swirly Date: Sun, 21 Jun 2026 07:34:22 -0500 Subject: [PATCH 19/31] t --- bridge/matrix/matrix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 43c69bc7db..6a1f662ee0 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -509,7 +509,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { return resp.EventID.String(), err } // Send a normal message - msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, *msg) + msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, &msg) if err != nil { return "", err } From 38413fd16aa05117d6978c33dcb60be456c2c072 Mon Sep 17 00:00:00 2001 From: Swirly Date: Sun, 21 Jun 2026 12:36:26 -0500 Subject: [PATCH 20/31] oh right thats redundant --- bridge/matrix/matrix.go | 42 ----------------------------------------- 1 file changed, 42 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 6a1f662ee0..57a416488e 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -466,48 +466,6 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { return resp.EventID.String(), err } - - if b.GetBool("UseMSC4144") { - body, _ = strings.CutPrefix(body, username.plain) - body = username.plain + ": " + body - formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) - formattedBody = "" + username.plain + ": " + formattedBody - - content := event.MessageEventContent{ - MsgType: event.MsgText, - Body: body, - FormattedBody: formattedBody, - Format: event.FormatHTML, - BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, - Displayname: username.plain, - HasFallback: true, - }, - } - - content.AddPerMessageProfileFallback() - - if b.GetBool("HTMLDisable") { - content.Format = "" - content.FormattedBody = "" - } - - var ( - resp *mautrix.RespSendEvent - err error - ) - - err = b.retry(func() error { - resp, err = b.mc.SendMessageEvent(context.TODO(), roomID, event.EventMessage, content) - - return err - }) - if err != nil { - return "", err - } - - return resp.EventID.String(), err - } // Send a normal message msgID, err := b.sendNormalMessage(roomID, body, formattedBody, username, &msg) if err != nil { From 178e6c707eb533da97a75d5a0652979f6eb0157e Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Sun, 21 Jun 2026 16:47:02 -0500 Subject: [PATCH 21/31] fix edits... again? --- bridge/matrix/matrix.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 57a416488e..107dbdcafa 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -320,6 +320,11 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { FormattedBody: formattedBody, Format: event.FormatHTML, MsgType: event.MsgText, + BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ + ID: msg.UserID, + Displayname: username.plain, + HasFallback: true, + }, }, RelatesTo: &event.RelatesTo{ EventID: id.EventID(msg.ID), From b5a48c23e2d39d44b677a4c197091fd284ebd68b Mon Sep 17 00:00:00 2001 From: Swirly Date: Mon, 22 Jun 2026 15:33:41 -0500 Subject: [PATCH 22/31] let non-PMPers know uploader --- bridge/matrix/matrix.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 107dbdcafa..726f39ff2d 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -989,6 +989,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Displayname: username.plain, HasFallback: true, }, + Format: event.FormatHTML, + FormattedBody: "" + username.plain + ": ", } content.AddPerMessageProfileFallback() @@ -1039,6 +1041,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Displayname: username.plain, HasFallback: true, }, + Format: event.FormatHTML, + FormattedBody: "" + username.plain + ": ", } img.AddPerMessageProfileFallback() @@ -1088,6 +1092,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Displayname: username.plain, HasFallback: true, }, + Format: event.FormatHTML, + FormattedBody: "" + username.plain + ": ", } content.AddPerMessageProfileFallback() @@ -1126,6 +1132,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Displayname: username.plain, HasFallback: true, }, + Format: event.FormatHTML, + FormattedBody: "" + username.plain + ": ", } content.AddPerMessageProfileFallback() From b775c918d98d979af01802e67e627a4f4018ed19 Mon Sep 17 00:00:00 2001 From: Swirly Date: Mon, 22 Jun 2026 17:29:43 -0500 Subject: [PATCH 23/31] let non-PMPers know uploader 2: electric PMP --- bridge/matrix/matrix.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 726f39ff2d..a89af058df 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -990,7 +990,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": ", + FormattedBody: "" + username.plain + ": " + fi.Name, + Body: username.plain + ": " + fi.Name, } content.AddPerMessageProfileFallback() @@ -1028,7 +1029,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co if b.GetBool("UseMSC4144") { img = event.MessageEventContent{ MsgType: event.MsgImage, - Body: fi.Name, + Body: username.plain + ": " + fi.Name, URL: id.ContentURIString(res.ContentURI.String()), Info: &event.FileInfo{ MimeType: mtype, @@ -1042,7 +1043,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": ", + FormattedBody: "" + username.plain + ": " + fi.Name, } img.AddPerMessageProfileFallback() @@ -1093,7 +1094,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": ", + FormattedBody: "" + username.plain + ": " + fi.Name, + Body: username.plain + ": " + fi.Name, } content.AddPerMessageProfileFallback() @@ -1133,7 +1135,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": ", + FormattedBody: "" + username.plain + ": " + fi.Name, + Body: username.plain + ": " + fi.Name, } content.AddPerMessageProfileFallback() From 02746b462f48407074930d11dd63604a5ec2afdc Mon Sep 17 00:00:00 2001 From: Swirly Date: Mon, 22 Jun 2026 17:34:02 -0500 Subject: [PATCH 24/31] hey turns out we forgot to send the filename. at all. --- bridge/matrix/matrix.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index a89af058df..99eca4e17c 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1028,9 +1028,10 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co var img event.MessageEventContent if b.GetBool("UseMSC4144") { img = event.MessageEventContent{ - MsgType: event.MsgImage, - Body: username.plain + ": " + fi.Name, - URL: id.ContentURIString(res.ContentURI.String()), + MsgType: event.MsgImage, + Body: username.plain + ": " + fi.Name, + FileName: fi.Name, + URL: id.ContentURIString(res.ContentURI.String()), Info: &event.FileInfo{ MimeType: mtype, Size: len(*fi.Data), From a3358ed4bda046c3ea71e377ab8ab9030b4d15a9 Mon Sep 17 00:00:00 2001 From: Swirly Date: Mon, 22 Jun 2026 20:39:25 -0500 Subject: [PATCH 25/31] blunder --- bridge/matrix/matrix.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 99eca4e17c..65600fa137 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -216,8 +216,8 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { if b.GetBool("UseMSC4144") { body, _ = strings.CutPrefix(body, username.plain) body = username.plain + ": " + body - formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) - formattedBody = "" + username.plain + ": " + formattedBody + formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) + formattedBody = "" + username.formatted + ": " + formattedBody content = event.MessageEventContent{ MsgType: event.MsgEmote, Body: body, @@ -308,8 +308,8 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { if b.GetBool("UseMSC4144") { body, _ = strings.CutPrefix(body, username.plain) body = username.plain + ": " + body - formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) - formattedBody = "" + username.plain + ": " + formattedBody + formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) + formattedBody = "" + username.formatted + ": " + formattedBody content = event.MessageEventContent{ Body: "* " + body, FormattedBody: "* " + formattedBody, @@ -413,8 +413,8 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { if b.GetBool("UseMSC4144") { body, _ = strings.CutPrefix(body, username.plain) body = username.plain + ": " + body - formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) - formattedBody = "" + username.plain + ": " + formattedBody + formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) + formattedBody = "" + username.formatted + ": " + formattedBody content = event.MessageEventContent{ MsgType: event.MsgText, @@ -990,7 +990,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": " + fi.Name, + FormattedBody: "" + username.formatted + ": " + fi.Name, Body: username.plain + ": " + fi.Name, } @@ -1044,7 +1044,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": " + fi.Name, + FormattedBody: "" + username.formatted + ": " + fi.Name, } img.AddPerMessageProfileFallback() @@ -1095,7 +1095,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": " + fi.Name, + FormattedBody: "" + username.formatted + ": " + fi.Name, Body: username.plain + ": " + fi.Name, } @@ -1136,7 +1136,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co HasFallback: true, }, Format: event.FormatHTML, - FormattedBody: "" + username.plain + ": " + fi.Name, + FormattedBody: "" + username.formatted + ": " + fi.Name, Body: username.plain + ": " + fi.Name, } @@ -1217,8 +1217,8 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted if b.GetBool("UseMSC4144") { body, _ = strings.CutPrefix(body, username.plain) body = username.plain + ": " + body - formattedBody, _ = strings.CutPrefix(formattedBody, username.plain) - formattedBody = "" + username.plain + ": " + formattedBody + formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) + formattedBody = "" + username.formatted + ": " + formattedBody content = event.MessageEventContent{ MsgType: event.MsgText, Body: body, From 8b6c469aa8dacf0421fe6b61bbf1173373f155c3 Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Wed, 24 Jun 2026 13:11:09 -0500 Subject: [PATCH 26/31] remove redundant stuff --- bridge/matrix/matrix.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 65600fa137..94808ea98f 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -229,8 +229,6 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { HasFallback: true, }, } - - content.AddPerMessageProfileFallback() } else { content = event.MessageEventContent{ MsgType: event.MsgEmote, @@ -336,8 +334,6 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { HasFallback: true, }, } - - content.AddPerMessageProfileFallback() } else { content = event.MessageEventContent{ Body: "* " + body, @@ -433,8 +429,6 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { HasFallback: true, }, } - - content.AddPerMessageProfileFallback() } else { content = event.MessageEventContent{ MsgType: event.MsgText, @@ -993,8 +987,6 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co FormattedBody: "" + username.formatted + ": " + fi.Name, Body: username.plain + ": " + fi.Name, } - - content.AddPerMessageProfileFallback() } else { content = event.MessageEventContent{ MsgType: event.MsgVideo, @@ -1098,8 +1090,6 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co FormattedBody: "" + username.formatted + ": " + fi.Name, Body: username.plain + ": " + fi.Name, } - - content.AddPerMessageProfileFallback() } else { content = event.MessageEventContent{ MsgType: event.MsgAudio, @@ -1139,8 +1129,6 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co FormattedBody: "" + username.formatted + ": " + fi.Name, Body: username.plain + ": " + fi.Name, } - - content.AddPerMessageProfileFallback() } else { content = event.MessageEventContent{ MsgType: event.MsgFile, From 190fb5a5748f55bc1cec94458f849e5bc275eac3 Mon Sep 17 00:00:00 2001 From: Swirly Date: Wed, 24 Jun 2026 16:23:44 -0500 Subject: [PATCH 27/31] add avatar support --- bridge/matrix/matrix.go | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 94808ea98f..5ef93b3910 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -218,6 +218,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { body = username.plain + ": " + body formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) formattedBody = "" + username.formatted + ": " + formattedBody + avatar := b.handleAvatar(msg.Avatar) content = event.MessageEventContent{ MsgType: event.MsgEmote, Body: body, @@ -226,6 +227,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, } @@ -308,6 +310,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { body = username.plain + ": " + body formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) formattedBody = "" + username.formatted + ": " + formattedBody + avatar := b.handleAvatar(msg.Avatar) content = event.MessageEventContent{ Body: "* " + body, FormattedBody: "* " + formattedBody, @@ -321,6 +324,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, }, @@ -331,6 +335,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, } @@ -411,6 +416,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { body = username.plain + ": " + body formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) formattedBody = "" + username.formatted + ": " + formattedBody + avatar := b.handleAvatar(msg.Avatar) content = event.MessageEventContent{ MsgType: event.MsgText, @@ -426,6 +432,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, } @@ -970,6 +977,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co err = b.retry(func() error { var content event.MessageEventContent if b.GetBool("UseMSC4144") { + avatar := b.handleAvatar(msg.Avatar) content = event.MessageEventContent{ MsgType: event.MsgVideo, FileName: fi.Name, @@ -981,6 +989,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, Format: event.FormatHTML, @@ -1019,6 +1028,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co var img event.MessageEventContent if b.GetBool("UseMSC4144") { + avatar := b.handleAvatar(msg.Avatar) img = event.MessageEventContent{ MsgType: event.MsgImage, Body: username.plain + ": " + fi.Name, @@ -1033,6 +1043,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, Format: event.FormatHTML, @@ -1073,6 +1084,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co err = b.retry(func() error { var content event.MessageEventContent if b.GetBool("UseMSC4144") { + avatar := b.handleAvatar(msg.Avatar) content = event.MessageEventContent{ MsgType: event.MsgAudio, FileName: fi.Name, @@ -1084,6 +1096,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, Format: event.FormatHTML, @@ -1112,6 +1125,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co err = b.retry(func() error { var content event.MessageEventContent if b.GetBool("UseMSC4144") { + avatar := b.handleAvatar(msg.Avatar) content = event.MessageEventContent{ MsgType: event.MsgFile, FileName: fi.Name, @@ -1123,6 +1137,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, Format: event.FormatHTML, @@ -1170,6 +1185,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user err = b.retry(func() error { if b.GetBool("UseMSC4144") { + avatar := b.handleAvatar(msg.Avatar) body, _ = strings.CutPrefix(body, username.plain) body = username.plain + ": " + body content := event.MessageEventContent{ @@ -1178,6 +1194,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, } @@ -1207,6 +1224,7 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted body = username.plain + ": " + body formattedBody, _ = strings.CutPrefix(formattedBody, username.formatted) formattedBody = "" + username.formatted + ": " + formattedBody + avatar := b.handleAvatar(msg.Avatar) content = event.MessageEventContent{ MsgType: event.MsgText, Body: body, @@ -1215,6 +1233,7 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ ID: msg.UserID, Displayname: username.plain, + AvatarURL: &avatar, HasFallback: true, }, } @@ -1237,3 +1256,27 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted return resp.EventID.String(), err } + +func (b *Bmatrix) handleAvatar(url string) id.ContentURIString { + resp, err := http.Get(url) + if err != nil { + return "" + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + return "" + } + sp := strings.Split(url, ".") + mtype := mime.TypeByExtension("." + sp[len(sp)-1]) + media := mautrix.ReqUploadMedia{ + Content: resp.Body, + ContentType: mtype, + ContentLength: resp.ContentLength, + } + + res, err := b.mc.UploadMedia(context.TODO(), media) + if err != nil { + return "" + } + return id.ContentURIString(res.ContentURI.String()) +} From 06e59eaeef63b783553810ed5299adad1784da68 Mon Sep 17 00:00:00 2001 From: Swirly Date: Wed, 24 Jun 2026 16:28:01 -0500 Subject: [PATCH 28/31] forgot the debug things --- bridge/matrix/matrix.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 5ef93b3910..e4dc450026 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1260,10 +1260,12 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted func (b *Bmatrix) handleAvatar(url string) id.ContentURIString { resp, err := http.Get(url) if err != nil { + b.Log.Debugf("HTTP GET for avater error: %#v", err) return "" } defer resp.Body.Close() if resp.StatusCode != 200 { + b.Log.Debugf("HTTP GET for avater error: status code %#v", resp.StatusCode) return "" } sp := strings.Split(url, ".") @@ -1276,6 +1278,7 @@ func (b *Bmatrix) handleAvatar(url string) id.ContentURIString { res, err := b.mc.UploadMedia(context.TODO(), media) if err != nil { + b.Log.Debugf("error uploading avatar to matrix homeserver: %#v", err) return "" } return id.ContentURIString(res.ContentURI.String()) From db6333c724144414e4b594bd9f99dc4406a7a31f Mon Sep 17 00:00:00 2001 From: Swirly Date: Wed, 24 Jun 2026 16:41:28 -0500 Subject: [PATCH 29/31] please the powers that be (the linter) --- bridge/matrix/matrix.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index e4dc450026..9411944e53 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -9,6 +9,7 @@ import ( "io" "mime" "net/http" + "net/url" "path" "regexp" "slices" @@ -1257,18 +1258,26 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted return resp.EventID.String(), err } -func (b *Bmatrix) handleAvatar(url string) id.ContentURIString { - resp, err := http.Get(url) +func (b *Bmatrix) handleAvatar(urlS string) id.ContentURIString { + u, err := url.Parse(urlS) + req, err := http.NewRequest(http.MethodGet, u.String(), nil) + client := &http.Client{} + resp, err := client.Do(req) if err != nil { - b.Log.Debugf("HTTP GET for avater error: %#v", err) + b.Log.Debugf("HTTP GET for avatar error: %#v", err) return "" } - defer resp.Body.Close() - if resp.StatusCode != 200 { - b.Log.Debugf("HTTP GET for avater error: status code %#v", resp.StatusCode) + defer func() { + if err := resp.Body.Close(); err != nil { + b.Log.Debugf("Error closing HTTP body: %#v", err) + } + }() + + if resp.StatusCode != http.StatusOK { + b.Log.Debugf("HTTP GET for avatar error: status code %#v", resp.StatusCode) return "" } - sp := strings.Split(url, ".") + sp := strings.Split(urlS, ".") mtype := mime.TypeByExtension("." + sp[len(sp)-1]) media := mautrix.ReqUploadMedia{ Content: resp.Body, From e27514098aced38754e5fd4d8b3a5155627b7d9e Mon Sep 17 00:00:00 2001 From: Swirly Date: Wed, 24 Jun 2026 16:48:25 -0500 Subject: [PATCH 30/31] please the powers that be (the linter) but make it work --- bridge/matrix/matrix.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 9411944e53..4a46286306 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -1260,15 +1260,23 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted func (b *Bmatrix) handleAvatar(urlS string) id.ContentURIString { u, err := url.Parse(urlS) - req, err := http.NewRequest(http.MethodGet, u.String(), nil) - client := &http.Client{} - resp, err := client.Do(req) if err != nil { + b.Log.Debugf("URL parse for avatar error: %#v", err) + return "" + } + req, err2 := http.NewRequest(http.MethodGet, u.String(), nil) + if err2 != nil { + b.Log.Debugf("HTTP GET for avatar error: %#v", err) + return "" + } + client := &http.Client{} + resp, err3 := client.Do(req) + if err3 != nil { b.Log.Debugf("HTTP GET for avatar error: %#v", err) return "" } defer func() { - if err := resp.Body.Close(); err != nil { + if err4 := resp.Body.Close(); err4 != nil { b.Log.Debugf("Error closing HTTP body: %#v", err) } }() @@ -1285,8 +1293,8 @@ func (b *Bmatrix) handleAvatar(urlS string) id.ContentURIString { ContentLength: resp.ContentLength, } - res, err := b.mc.UploadMedia(context.TODO(), media) - if err != nil { + res, err5 := b.mc.UploadMedia(context.TODO(), media) + if err5 != nil { b.Log.Debugf("error uploading avatar to matrix homeserver: %#v", err) return "" } From 49a67e702c9b2bae5e10899bda8dbac69ec0136e Mon Sep 17 00:00:00 2001 From: Swirly <93798899+SwirlyStone5877@users.noreply.github.com> Date: Mon, 6 Jul 2026 08:36:32 -0500 Subject: [PATCH 31/31] combine user id and displayname/nick for msc4144 id --- bridge/matrix/matrix.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 8f3fdf82e8..4d28d54752 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -237,7 +237,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { FormattedBody: formattedBody, Format: event.FormatHTML, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -334,7 +334,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { Format: event.FormatHTML, MsgType: event.MsgText, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -345,7 +345,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { Type: event.RelReplace, }, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -444,7 +444,7 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) { }, }, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -1052,7 +1052,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Size: len(*fi.Data), }, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -1106,7 +1106,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Height: cfg.Height, // #nosec G115 -- go std will not returned negative size }, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -1159,7 +1159,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Size: len(*fi.Data), }, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -1200,7 +1200,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co Size: len(*fi.Data), }, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -1257,7 +1257,7 @@ func (b *Bmatrix) sendNormalMessagePlaintext(roomID id.RoomID, body string, user MsgType: event.MsgText, Body: body, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true, @@ -1296,7 +1296,7 @@ func (b *Bmatrix) sendNormalMessageHTML(roomID id.RoomID, body string, formatted FormattedBody: formattedBody, Format: event.FormatHTML, BeeperPerMessageProfile: &event.BeeperPerMessageProfile{ - ID: msg.UserID, + ID: msg.UserID + "/" + username.plain, Displayname: username.plain, AvatarURL: &avatar, HasFallback: true,