summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-01-20 18:19:17 +0100
committerWim <wim@42.be>2018-01-20 18:19:17 +0100
commit7119e378a7c01fea76f6541fdcc081827862ce66 (patch)
tree7ddae17146389e2f68141b077b54d1515809aac5 /bridge
parente1dc3032c1d4585ce072524b2b32ea75f851a914 (diff)
downloadmatterbridge-msglm-7119e378a7c01fea76f6541fdcc081827862ce66.tar.gz
matterbridge-msglm-7119e378a7c01fea76f6541fdcc081827862ce66.tar.bz2
matterbridge-msglm-7119e378a7c01fea76f6541fdcc081827862ce66.zip
Add an extension to images without one (matrix). #331
Diffstat (limited to 'bridge')
-rw-r--r--bridge/matrix/matrix.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go
index 4cc524ea..d659aaa2 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -205,6 +205,20 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
info := ev.Content["info"].(map[string]interface{})
size := info["size"].(float64)
name := ev.Content["body"].(string)
+ // check if we have an image uploaded without extension
+ if !strings.Contains(name, ".") {
+ if ev.Content["msgtype"].(string) == "m.image" {
+ if mtype, ok := ev.Content["mimetype"].(string); ok {
+ mext, _ := mime.ExtensionsByType(mtype)
+ if len(mext) > 0 {
+ name = name + mext[0]
+ }
+ } else {
+ // just a default .png extension if we don't have mime info
+ name = name + ".png"
+ }
+ }
+ }
flog.Debugf("trying to download %#v with size %#v", name, size)
if size <= float64(b.General.MediaDownloadSize) {
data, err := helper.DownloadFile(url)