send URL for files if config is set to send URLs

This commit is contained in:
other8026 2024-02-12 16:10:53 +08:00
parent 2f12fa3c61
commit fd38b8d54a

View File

@ -540,9 +540,18 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
// Do we have attachments // Do we have attachments
if b.containsAttachment(ev.Content) { if b.containsAttachment(ev.Content) {
err := b.handleDownloadFile(&rmsg, ev.Content) if b.GetBool("SendUrlNotFile") {
if err != nil { // replace the text of the message (which is set to the filename above) with the url
b.Log.Errorf("download failed: %#v", err) var err error
rmsg.Text, err = b.getMessageFileUrl(ev.Content)
if err != nil {
b.Log.Errorf("get url for uploaded file failed: %#v", err)
}
} else {
err := b.handleDownloadFile(&rmsg, ev.Content)
if err != nil {
b.Log.Errorf("download failed: %#v", err)
}
} }
} }