diff options
author | Wim <wim@42.be> | 2018-02-03 01:11:11 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-03 01:11:11 +0100 |
commit | 80822b7fff85647ad5852b00ec36d046959aed92 (patch) | |
tree | f3f15769f5b75b53f97c3bedf1bbf6a1f9a909c8 /bridge/mattermost | |
parent | 78f1011f529981bab58556d9847488db04d00388 (diff) | |
download | matterbridge-msglm-80822b7fff85647ad5852b00ec36d046959aed92.tar.gz matterbridge-msglm-80822b7fff85647ad5852b00ec36d046959aed92.tar.bz2 matterbridge-msglm-80822b7fff85647ad5852b00ec36d046959aed92.zip |
Send chat notification if media is too big to be re-uploaded to MediaServer. See #359
Diffstat (limited to 'bridge/mattermost')
-rw-r--r-- | bridge/mattermost/mattermost.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 7f5b6f8e..1f42b437 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "github.com/42wim/matterbridge/bridge/config" + "github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/matterclient" "github.com/42wim/matterbridge/matterhook" log "github.com/Sirupsen/logrus" @@ -154,6 +155,12 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) { if b.Config.WebhookURL != "" { if msg.Extra != nil { + for _, rmsg := range helper.HandleExtra(&msg, b.General) { + matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Channel: channel, UserName: rmsg.Username, + Text: rmsg.Text, Props: make(map[string]interface{})} + matterMessage.Props["matterbridge"] = true + b.mh.Send(matterMessage) + } if len(msg.Extra["file"]) > 0 { for _, f := range msg.Extra["file"] { fi := f.(config.FileInfo) @@ -186,6 +193,9 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) { return msg.ID, b.mc.DeleteMessage(msg.ID) } if msg.Extra != nil { + for _, rmsg := range helper.HandleExtra(&msg, b.General) { + b.mc.PostMessage(b.mc.GetChannelId(channel, ""), rmsg.Username+rmsg.Text) + } if len(msg.Extra["file"]) > 0 { var err error var res, id string @@ -296,6 +306,8 @@ func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) { flog.Debugf("trying to download %#v fileid %#v with size %#v", finfo.Name, finfo.Id, finfo.Size) if int(finfo.Size) > b.General.MediaDownloadSize { flog.Errorf("File %#v to large to download (%#v). MediaDownloadSize is %#v", finfo.Name, finfo.Size, b.General.MediaDownloadSize) + m.Event = config.EVENT_FILE_FAILURE_SIZE + m.Extra[m.Event] = append(m.Extra[m.Event], config.FileInfo{Name: finfo.Name, Comment: message.Text, Size: int64(finfo.Size)}) continue } data, resp := b.mc.Client.DownloadFile(id, true) |