Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
matrix: Attachment message body is actually caption
  • Loading branch information
selfhoster1312 committed Mar 2, 2026
commit 18aed0194183d93152f3d17c24996f32cbc855be
9 changes: 8 additions & 1 deletion bridge/matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,8 @@ func (b *Bmatrix) handleDownloadFile(rmsg *config.Message, content event.Content
if name, ok = content.Raw["body"].(string); !ok {
return fmt.Errorf("name isn't a %T", name)
}
// The attachment caption is the raw, unadultered message body
caption := name

if msgtype, ok = content.Raw["msgtype"].(string); !ok {
return fmt.Errorf("msgtype isn't a %T", msgtype)
Expand All @@ -798,8 +800,13 @@ func (b *Bmatrix) handleDownloadFile(rmsg *config.Message, content event.Content
}
}

// Now that we have performed sanity checks and edited the filename,
// remove the message "body" (which was parsed into the filename) so
// we don't have duplicates later on.
rmsg.Text = ""

// TODO: add attachment ID?
err := b.AddAttachmentFromProtectedURL(rmsg, name, "", "", url)
err := b.AddAttachmentFromProtectedURL(rmsg, name, "", caption, url)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
the return code is not 200 to avoid saving trash data ([#20](https://github.com/matterbridge-org/matterbridge/pull/20))
- matrix
- attachments received from matrix are working again, with authenticated media (MSC3916) implemented ([#61](https://github.com/matterbridge-org/matterbridge/pull/61))
- attachment body is treated as attachment caption and will no longer produce bogus text messages on other bridges
- image attachments are now sent as images with more metadata ([#61](https://github.com/matterbridge-org/matterbridge/pull/61))
- xmpp
- various upstream go-xmpp changes fix connection on SASL2 with PLAIN auth
Expand Down