summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-04-18 22:30:49 +0200
committerGitHub <noreply@github.com>2020-04-18 22:30:49 +0200
commit57794b3b9f246c2ae08f8709f05d39b4fc420f29 (patch)
treefcd933e6bca1f966cdb043635850a42078c38106 /bridge
parent3c36f651beafbaeca36a7112a47378e8a4d19d7d (diff)
downloadmatterbridge-msglm-57794b3b9f246c2ae08f8709f05d39b4fc420f29.tar.gz
matterbridge-msglm-57794b3b9f246c2ae08f8709f05d39b4fc420f29.tar.bz2
matterbridge-msglm-57794b3b9f246c2ae08f8709f05d39b4fc420f29.zip
Prevent image/message looping (slack). Fixes #1088 (#1096)
Also check for our matterbridge ID in Blocks set in SubMessages.
Diffstat (limited to 'bridge')
-rw-r--r--bridge/slack/handlers.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go
index 88136cba..56e112d2 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -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.
@@ -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 {
+ 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 {