diff options
author | Wim <wim@42.be> | 2017-12-19 23:44:13 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-12-19 23:44:13 +0100 |
commit | d0c4fe78eedc883049b684899cee87985ee36680 (patch) | |
tree | ba04699eb3e2557a8a0d6a7806b8e9b8b2a72656 /bridge | |
parent | 265457b45171dcae96a1aac9454e3bda2cd0557a (diff) | |
download | matterbridge-msglm-d0c4fe78eedc883049b684899cee87985ee36680.tar.gz matterbridge-msglm-d0c4fe78eedc883049b684899cee87985ee36680.tar.bz2 matterbridge-msglm-d0c4fe78eedc883049b684899cee87985ee36680.zip |
Allow specifying maximum download size of media using MediaDownloadSize (slack,telegram,matrix)
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/config/config.go | 3 | ||||
-rw-r--r-- | bridge/matrix/matrix.go | 2 | ||||
-rw-r--r-- | bridge/slack/slack.go | 2 | ||||
-rw-r--r-- | bridge/telegram/telegram.go | 2 |
4 files changed, 6 insertions, 3 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go index 10f1d5f0..69531440 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -182,6 +182,9 @@ func NewConfig(cfgfile string) *Config { if fail { log.Fatalf("Fix your config. Please see changelog for more information") } + if cfg.General.MediaDownloadSize == 0 { + cfg.General.MediaDownloadSize = 1000000 + } return &cfg } diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index 03e493f7..7e326c22 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -175,7 +175,7 @@ func (b *Bmatrix) handlematrix() error { size := info["size"].(float64) name := ev.Content["body"].(string) flog.Debugf("trying to download %#v with size %#v", name, size) - if size <= 1000000 { + if size <= float64(b.General.MediaDownloadSize) { data, err := helper.DownloadFile(url) if err != nil { flog.Errorf("download %s failed %#v", url, err) diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index d6f73ffd..51fe698d 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -288,7 +288,7 @@ func (b *Bslack) handleSlack() { // if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra if message.Raw.File != nil { // limit to 1MB for now - if message.Raw.File.Size <= 1000000 { + if message.Raw.File.Size <= b.General.MediaDownloadSize { comment := "" data, err := b.downloadFile(message.Raw.File.URLPrivateDownload) if err != nil { diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 95492a88..2aabf3a8 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -299,7 +299,7 @@ func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) { // if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra // limit to 1MB for now flog.Debugf("trying to download %#v fileid %#v with size %#v", name, fileid, size) - if size <= 1000000 { + if size <= b.General.MediaDownloadSize { data, err := helper.DownloadFile(url) if err != nil { flog.Errorf("download %s failed %#v", url, err) |