From 57f156be8328529666aadaee780711f12b6e162b Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 10 Feb 2019 17:23:50 +0100 Subject: Hint at thread replies when messages are unthreaded (slack) (#684) --- bridge/slack/helpers.go | 7 +++++++ bridge/slack/slack.go | 6 ++++++ 2 files changed, 13 insertions(+) (limited to 'bridge/slack') diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go index 9959d4fa..4d191c0d 100644 --- a/bridge/slack/helpers.go +++ b/bridge/slack/helpers.go @@ -254,6 +254,13 @@ 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 001b1268..1685c4fc 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -293,6 +293,12 @@ 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 -- cgit v1.2.3