4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-08-10 19:58:09 +00:00

Relay attachments from mattermost to slack (slack). Closes #260

This commit is contained in:
Wim
2017-09-18 23:51:27 +02:00
parent 27d886826c
commit 1a40b0c1e9
4 changed files with 51 additions and 2 deletions

View File

@@ -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
}