summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-10-27 00:06:44 +0200
committerGitHub <noreply@github.com>2019-10-27 00:06:44 +0200
commit727fa9f92971a29eaa1790fb249bd3a7baa919f6 (patch)
tree414d2f228a4572d5aa17e765d5f4579484392a91
parent0b9bc18236055fdb785a878b3a0f40f73102f8ef (diff)
downloadmatterbridge-msglm-727fa9f92971a29eaa1790fb249bd3a7baa919f6.tar.gz
matterbridge-msglm-727fa9f92971a29eaa1790fb249bd3a7baa919f6.tar.bz2
matterbridge-msglm-727fa9f92971a29eaa1790fb249bd3a7baa919f6.zip
Add support for uploading application/x and audio/x (matrix). Fixes #925 (#929)
-rw-r--r--bridge/matrix/matrix.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go
index f76c4ab8..16562c79 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -291,7 +291,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *conf
content := bytes.NewReader(*fi.Data)
sp := strings.Split(fi.Name, ".")
mtype := mime.TypeByExtension("." + sp[len(sp)-1])
- if !strings.Contains(mtype, "image") && !strings.Contains(mtype, "video") {
+ if !(strings.Contains(mtype, "image") || strings.Contains(mtype, "video") ||
+ strings.Contains(mtype, "application") || strings.Contains(mtype, "audio")) {
return
}
if fi.Comment != "" {
@@ -326,6 +327,18 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *conf
if err != nil {
b.Log.Errorf("sendImage failed: %#v", err)
}
+ case strings.Contains(mtype, "application"):
+ b.Log.Debugf("sendFile %s", res.ContentURI)
+ _, err = b.mc.SendFile(channel, fi.Name, res.ContentURI, mtype, uint(len(*fi.Data)))
+ if err != nil {
+ b.Log.Errorf("sendFile failed: %#v", err)
+ }
+ case strings.Contains(mtype, "audio"):
+ b.Log.Debugf("sendAudio %s", res.ContentURI)
+ _, err = b.mc.SendAudio(channel, fi.Name, res.ContentURI, mtype, uint(len(*fi.Data)))
+ if err != nil {
+ b.Log.Errorf("sendAudio failed: %#v", err)
+ }
}
b.Log.Debugf("result: %#v", res)
}