diff options
author | Wim <wim@42.be> | 2017-09-18 23:51:27 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-09-18 23:51:27 +0200 |
commit | 1a40b0c1e9dd9772d760a68f2998b3bcb0f8a413 (patch) | |
tree | 794e03cd33a9ed1c4aded7040f81bd7803ec8e7b /bridge/slack/slack.go | |
parent | 27d886826cd124feded6d7856847687568a395d0 (diff) | |
download | matterbridge-msglm-1a40b0c1e9dd9772d760a68f2998b3bcb0f8a413.tar.gz matterbridge-msglm-1a40b0c1e9dd9772d760a68f2998b3bcb0f8a413.tar.bz2 matterbridge-msglm-1a40b0c1e9dd9772d760a68f2998b3bcb0f8a413.zip |
Relay attachments from mattermost to slack (slack). Closes #260
Diffstat (limited to 'bridge/slack/slack.go')
-rw-r--r-- | bridge/slack/slack.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index fa847db9..21163116 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -163,6 +163,8 @@ func (b *Bslack) Send(msg config.Message) (string, error) { np.IconURL = msg.Avatar } np.Attachments = append(np.Attachments, slack.Attachment{CallbackID: "matterbridge"}) + np.Attachments = append(np.Attachments, b.createAttach(msg.Extra)...) + // replace mentions np.LinkNames = 1 @@ -389,3 +391,28 @@ func (b *Bslack) replaceURL(text string) string { } return text } + +func (b *Bslack) createAttach(extra []interface{}) []slack.Attachment { + var attachs []slack.Attachment + if extra != nil { + for _, v := range extra { + entry := v.(map[string]interface{}) + s := slack.Attachment{} + s.Fallback = entry["fallback"].(string) + s.Color = entry["color"].(string) + s.Pretext = entry["pretext"].(string) + s.AuthorName = entry["author_name"].(string) + s.AuthorLink = entry["author_link"].(string) + s.AuthorIcon = entry["author_icon"].(string) + s.Title = entry["title"].(string) + s.TitleLink = entry["title_link"].(string) + s.Text = entry["text"].(string) + s.ImageURL = entry["image_url"].(string) + s.ThumbURL = entry["thumb_url"].(string) + s.Footer = entry["footer"].(string) + s.FooterIcon = entry["footer_icon"].(string) + attachs = append(attachs, s) + } + } + return attachs +} |