From 1a40b0c1e9dd9772d760a68f2998b3bcb0f8a413 Mon Sep 17 00:00:00 2001 From: Wim Date: Mon, 18 Sep 2017 23:51:27 +0200 Subject: Relay attachments from mattermost to slack (slack). Closes #260 --- bridge/mattermost/mattermost.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bridge/mattermost') diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 41a3f273..f9e350e8 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -26,6 +26,7 @@ type MMMessage struct { UserID string ID string Event string + Extra []interface{} } type Bmattermost struct { @@ -195,7 +196,7 @@ func (b *Bmattermost) handleMatter() { go b.handleMatterClient(mchan) } for message := range mchan { - rmsg := config.Message{Username: message.Username, Channel: message.Channel, Account: b.Account, UserID: message.UserID, ID: message.ID, Event: message.Event} + rmsg := config.Message{Username: message.Username, Channel: message.Channel, Account: b.Account, UserID: message.UserID, ID: message.ID, Event: message.Event, Extra: message.Extra} text, ok := b.replaceAction(message.Text) if ok { rmsg.Event = config.EVENT_USER_ACTION @@ -220,11 +221,17 @@ func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) { if (message.Raw.Event == "post_edited") && b.Config.EditDisable { continue } + + m := &MMMessage{} + props := message.Post.Props if props != nil { if _, ok := props["override_username"].(string); ok { message.Username = props["override_username"].(string) } + if _, ok := props["attachments"].([]interface{}); ok { + m.Extra = props["attachments"].([]interface{}) + } } // do not post our own messages back to irc // only listen to message from our team @@ -235,7 +242,6 @@ func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) { continue } flog.Debugf("Receiving from matterclient %#v", message) - m := &MMMessage{} m.UserID = message.UserID m.Username = message.Username m.Channel = message.Channel -- cgit v1.2.3