From 8971502f31bface9312a6d0baecac8ded22b2502 Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Wed, 24 Oct 2018 17:03:00 +0800 Subject: [PATCH] Allowed Slack attachments to be properly updated on edit. --- bridge/slack/slack.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index caa8da17..44be43ae 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -270,18 +270,20 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) { msg.Text = msg.Username + msg.Text } + var messageOptions []slack.MsgOption + // Edit message if we have an ID if msg.ID != "" { ts := strings.Fields(msg.ID) - _, _, _, err = b.sc.UpdateMessage(channelInfo.ID, ts[1], slack.MsgOptionText(msg.Text, false)) + messageOptions = b.prepareMessageOptions(msg) + messageOptions = append(messageOptions, slack.MsgOptionText(msg.Text, false)) + _, _, _, err = b.sc.UpdateMessage(channelInfo.ID, ts[1], messageOptions...) if err != nil { return msg.ID, err } return msg.ID, nil } - var messageOptions []slack.MsgOption - // Upload a file if it exists if msg.Extra != nil { for _, rmsg := range helper.HandleExtra(&msg, b.General) {