Skip to content

Commit

Permalink
Prevent image/message looping (slack). Fixes #1088
Browse files Browse the repository at this point in the history
Also check for our matterbridge ID in Blocks set in SubMessages.
  • Loading branch information
42wim committed Apr 18, 2020
1 parent 0047e6f commit 43dab07
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bridge/slack/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ func (b *Bslack) skipMessageEvent(ev *slack.MessageEvent) bool {
hasOurCallbackID = ok && block.BlockID == "matterbridge_"+b.uuid
}

// Skip any messages that we made ourselves or from 'slackbot' (see #527).
if ev.Username == sSlackBotUser ||
(b.rtm != nil && ev.Username == b.si.User.Name) || hasOurCallbackID {
return true
}

if ev.SubMessage != nil {
// It seems ev.SubMessage.Edited == nil when slack unfurls.
// Do not forward these messages. See Github issue #266.
Expand All @@ -155,6 +149,16 @@ func (b *Bslack) skipMessageEvent(ev *slack.MessageEvent) bool {
if ev.SubType == "message_replied" && ev.Hidden {
return true
}
if len(ev.SubMessage.Blocks.BlockSet) == 1 {

This comment has been minimized.

Copy link
@qaisjp

qaisjp Apr 18, 2020

Collaborator

When Slack unfurls URLs, does it edit the message with additional blocks, or does it edit the Attachments?

block, ok := ev.SubMessage.Blocks.BlockSet[0].(*slack.SectionBlock)
hasOurCallbackID = ok && block.BlockID == "matterbridge_"+b.uuid
}
}

// Skip any messages that we made ourselves or from 'slackbot' (see #527).
if ev.Username == sSlackBotUser ||
(b.rtm != nil && ev.Username == b.si.User.Name) || hasOurCallbackID {
return true
}

if len(ev.Files) > 0 {
Expand Down

0 comments on commit 43dab07

Please sign in to comment.