Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit e02b2089532f91bb91c6ce17e51ffc838430242f Author: Wim <wim@42.be> Date: Sun Feb 10 17:23:50 2019 +0000 Hint at thread replies when messages are unthreaded (slack) (#684) diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go index 9959d4f..4d191c0 100644 --- a/bridge/slack/helpers.go +++ b/bridge/slack/helpers.go @@ -2546 +25413 @@ func (b *Bslack) populateReceivedMessage(ev *slack.MessageEvent) (*config.Messag   }   }   + // For edits, only submessage has thread ts. + // Ensures edits to threaded messages maintain their prefix hint on the + // unthreaded end. + if ev.SubMessage != nil { + rmsg.ParentID = ev.SubMessage.ThreadTimestamp + } +   if err = b.populateMessageWithUserInfo(ev, rmsg); err != nil {   return nil, err   } diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 001b126..1685c4f 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -2936 +29312 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {   return "", err   }   + // Handle prefix hint for unthreaded messages. + if msg.ParentID == "msg-parent-not-found" { + msg.ParentID = "" + msg.Text = fmt.Sprintf("[thread]: %s", msg.Text) + } +   // Handle message deletions.   if handled, err = b.deleteMessage(&msg, channelInfo); handled {   return msg.ID, err diff --git a/gateway/gateway.go b/gateway/gateway.go index 6fe1996..72d0831 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -3986 +39812 @@ func (gw *Gateway) SendMessage(origmsg config.Message, dest *bridge.Bridge, chan   msg.ParentID = canonicalParentMsgID   }   + // if the parentID is still empty and we have a parentID set in the original message + // this means that we didn't find it in the cache so set it "msg-parent-not-found" + if msg.ParentID == "" && origmsg.ParentID != "" { + msg.ParentID = "msg-parent-not-found" + } +   // if we are using mattermost plugin account, send messages to MattermostPlugin channel   // that can be picked up by the mattermost matterbridge plugin   if dest.Account == "mattermost.plugin" {