mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-26 16:39:24 +00:00
Allow specifying maximum download size of media using MediaDownloadSize (slack,telegram,matrix)
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user