5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-29 14:01:35 +00:00

Add support to upload files to slack, from bridges with private urls like slack/mattermost/telegram. (slack)

This commit is contained in:
Wim 2017-11-03 23:10:16 +01:00
parent d1e04a2ece
commit 6f18790352

View File

@ -187,6 +187,25 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
b.sc.UpdateMessage(schannel.ID, ts[1], message) b.sc.UpdateMessage(schannel.ID, ts[1], message)
return "", nil 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) _, id, err := b.sc.PostMessage(schannel.ID, message, np)
if err != nil { if err != nil {
return "", err return "", err