diff options
author | Wim <wim@42.be> | 2017-11-03 23:10:16 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-11-03 23:10:16 +0100 |
commit | 6f187903522dc629c4c4f3171775f83021dcc4e5 (patch) | |
tree | d9f7a29a98773e14b471342a8537f2533b9d9740 /bridge/slack | |
parent | d1e04a2ece6517ea094eebdff30a9bbe3c6be593 (diff) | |
download | matterbridge-msglm-6f187903522dc629c4c4f3171775f83021dcc4e5.tar.gz matterbridge-msglm-6f187903522dc629c4c4f3171775f83021dcc4e5.tar.bz2 matterbridge-msglm-6f187903522dc629c4c4f3171775f83021dcc4e5.zip |
Add support to upload files to slack, from bridges with private urls like slack/mattermost/telegram. (slack)
Diffstat (limited to 'bridge/slack')
-rw-r--r-- | bridge/slack/slack.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 11a84a12..74003753 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -187,6 +187,25 @@ func (b *Bslack) Send(msg config.Message) (string, error) { b.sc.UpdateMessage(schannel.ID, ts[1], message) return "", nil } + + if msg.Extra != nil { + // check if we have files to upload (from slack, telegram or mattermost) + if len(msg.Extra["file"]) > 0 { + var err error + for _, f := range msg.Extra["file"] { + fi := f.(config.FileInfo) + _, err = b.sc.UploadFile(slack.FileUploadParameters{ + Reader: bytes.NewReader(*fi.Data), + Filename: fi.Name, + Channels: []string{schannel.ID}, + }) + if err != nil { + flog.Errorf("uploadfile %#v", err) + } + } + } + } + _, id, err := b.sc.PostMessage(schannel.ID, message, np) if err != nil { return "", err |