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,11 +540,20 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
// Do we have attachments
if b.containsAttachment(ev.Content) {
if b.GetBool("SendUrlNotFile") {
// replace the text of the message (which is set to the filename above) with the url
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)
}
}
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", ev.Sender, b.Account)
b.Remote <- rmsg