From fd38b8d54a9f9034bbd662b1be2f00fe6a6f4eb4 Mon Sep 17 00:00:00 2001 From: other8026 <146984625+other8026@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:10:53 +0800 Subject: [PATCH] send URL for files if config is set to send URLs --- bridge/matrix/matrix.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 487a831f..2b805214 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -540,9 +540,18 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) { // Do we have attachments if b.containsAttachment(ev.Content) { - err := b.handleDownloadFile(&rmsg, ev.Content) - if err != nil { - b.Log.Errorf("download failed: %#v", err) + 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) + } } }