Skip to content

Commit 36709fb

Browse files
matrix: Attachment message body is actually caption
1 parent ccf4349 commit 36709fb

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

bridge/matrix/matrix.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ func (b *Bmatrix) handleDownloadFile(rmsg *config.Message, content event.Content
776776
if name, ok = content.Raw["body"].(string); !ok {
777777
return fmt.Errorf("name isn't a %T", name)
778778
}
779+
// The attachment caption is the raw, unadultered message body
780+
caption := name
779781

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

803+
// Now that we have performed sanity checks and edited the filename,
804+
// remove the message "body" (which was parsed into the filename) so
805+
// we don't have duplicates later on.
806+
rmsg.Text = ""
807+
801808
// TODO: add attachment ID?
802-
err := b.AddAttachmentFromProtectedURL(rmsg, name, "", "", url)
809+
err := b.AddAttachmentFromProtectedURL(rmsg, name, "", caption, url)
803810
if err != nil {
804811
return err
805812
}

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
the return code is not 200 to avoid saving trash data ([#20](https://github.com/matterbridge-org/matterbridge/pull/20))
5353
- matrix
5454
- attachments received from matrix are working again, with authenticated media (MSC3916) implemented ([#61](https://github.com/matterbridge-org/matterbridge/pull/61))
55+
- attachment body is treated as attachment caption and will no longer produce bogus text messages on other bridges
5556
- image attachments are now sent as images with more metadata ([#61](https://github.com/matterbridge-org/matterbridge/pull/61))
5657
- xmpp
5758
- various upstream go-xmpp changes fix connection on SASL2 with PLAIN auth

0 commit comments

Comments
 (0)