diff options
author | Wim <wim@42.be> | 2018-06-09 14:35:02 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-06-09 14:35:02 +0200 |
commit | bd9ea7a88dc44f92516315aa1e997a7c1b0e616d (patch) | |
tree | 0382dbd4105f2c0061a70491339493a54c150c43 /bridge/helper | |
parent | 51327a405651442ac47c4ce75363442fa323b592 (diff) | |
download | matterbridge-msglm-bd9ea7a88dc44f92516315aa1e997a7c1b0e616d.tar.gz matterbridge-msglm-bd9ea7a88dc44f92516315aa1e997a7c1b0e616d.tar.bz2 matterbridge-msglm-bd9ea7a88dc44f92516315aa1e997a7c1b0e616d.zip |
Add MediaDownloadBlacklist option. Closes #442
Diffstat (limited to 'bridge/helper')
-rw-r--r-- | bridge/helper/helper.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go index a3f4255c..13d94ede 100644 --- a/bridge/helper/helper.go +++ b/bridge/helper/helper.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "regexp" "strings" "time" @@ -73,6 +74,19 @@ func GetAvatar(av map[string]string, userid string, general *config.Protocol) st } func HandleDownloadSize(flog *log.Entry, msg *config.Message, name string, size int64, general *config.Protocol) error { + // check blacklist here + for _, entry := range general.MediaDownloadBlackList { + if entry != "" { + re, err := regexp.Compile(entry) + if err != nil { + flog.Errorf("incorrect regexp %s for %s", entry, msg.Account) + continue + } + if re.MatchString(name) { + return fmt.Errorf("Matching blacklist %s. Not downloading %s", entry, name) + } + } + } flog.Debugf("Trying to download %#v with size %#v", name, size) if int(size) > general.MediaDownloadSize { msg.Event = config.EVENT_FILE_FAILURE_SIZE |