summaryrefslogtreecommitdiffstats
path: root/bridge/xmpp/xmpp.go
diff options
context:
space:
mode:
authorValdikSS <iam@valdikss.org.ru>2018-05-10 00:04:10 +0300
committerWim <wim@42.be>2018-05-09 23:04:10 +0200
commitbe04d1a8627456f07c8ab9800d12532211897991 (patch)
tree5db7e2a7f459adee154da79dcf39647948ba157f /bridge/xmpp/xmpp.go
parent85b2d5a1247d1cf610bd5de9bd1240e738d5d011 (diff)
downloadmatterbridge-msglm-be04d1a8627456f07c8ab9800d12532211897991.tar.gz
matterbridge-msglm-be04d1a8627456f07c8ab9800d12532211897991.tar.bz2
matterbridge-msglm-be04d1a8627456f07c8ab9800d12532211897991.zip
Send attached files to XMPP in different message with OOB data and without body (#421)
Conversations can't show inline pictures if there's anything besides URL in the message body. Workaround this issue by sending one usual message and one message with OOB data and without message body. The second message should not be shown in the clients without OOB support, so the user won't see the empty message.
Diffstat (limited to 'bridge/xmpp/xmpp.go')
-rw-r--r--bridge/xmpp/xmpp.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index 17cadf06..8a066751 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -180,6 +180,7 @@ func (b *Bxmpp) replaceAction(text string) (string, bool) {
// handleUploadFile handles native upload of files
func (b *Bxmpp) handleUploadFile(msg *config.Message) (string, error) {
+ var urldesc = ""
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
if fi.Comment != "" {
@@ -189,12 +190,16 @@ func (b *Bxmpp) handleUploadFile(msg *config.Message) (string, error) {
msg.Text = fi.URL
if fi.Comment != "" {
msg.Text = fi.Comment + ": " + fi.URL
+ urldesc = fi.Comment
}
}
_, err := b.xc.Send(xmpp.Chat{Type: "groupchat", Remote: msg.Channel + "@" + b.GetString("Muc"), Text: msg.Username + msg.Text})
if err != nil {
return "", err
}
+ if fi.URL != "" {
+ b.xc.SendOOB(xmpp.Chat{Type: "groupchat", Remote: msg.Channel + "@" + b.GetString("Muc"), Ooburl: fi.URL, Oobdesc: urldesc})
+ }
}
return "", nil
}