commit 73f158d761ef79911f386c0877d0ee95610eeb60
Author: Wim <wim@42.be>
Date: Sat Jun 09 14:35:02 2018 +0000
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 351e6ca..0fa76b5 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -7410 +7411 @@ type Protocol struct {
Jid string // xmpp
Label string // all protocols
Login string // mattermost, matrix
+ MediaDownloadBlackList []string
+ MediaDownloadPath string // Basically MediaServerUpload, but instead of uploading it, just write it to a file on the same server.
MediaDownloadSize int // all protocols
MediaServerDownload string
MediaServerUpload string
- MediaDownloadPath string // Basically MediaServerUpload, but instead of uploading it, just write it to a file on the same server.
MessageDelay int // IRC, time in millisecond to wait between messages
MessageFormat string // telegram
MessageLength int // IRC, max length of a message allowed
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go
index a3f4255..13d94ed 100644
--- a/bridge/helper/helper.go
+++ b/bridge/helper/helper.go
@@ -56 +57 @@ import (
"fmt"
"io"
"net/http"
+ "regexp"
"strings"
"time"
@@ -736 +7419 @@ 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
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index 1bc4f3b..2a77bca 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -13319 +133115 @@ MediaServerDownload="https://youserver.com/download"
#It will only download from bridges that don't have public links available, which are for the moment
#slack, telegram, matrix and mattermost
#
-#Optional (default 1000000 (1 megabyte))
+#OPTIONAL (default 1000000 (1 megabyte))
MediaDownloadSize=1000000
+#MediaDownloadBlacklist allows you to blacklist specific files from being downloaded.
+#Filenames matching these regexp will not be download/uploaded to the mediaserver
+#You can use regex for this, see https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (default empty)
+MediaDownloadBlacklist=[".html$",".htm$"]
+
###################################################################
#Gateway configuration
###################################################################