summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQais Patankar <qaisjp@gmail.com>2020-12-31 16:21:37 +0000
committerGitHub <noreply@github.com>2020-12-31 16:21:37 +0000
commit1a4717b366a2371dacc0ce205b0a42c5b31f52dc (patch)
tree1562058547958f29a3853ef9ab08d38ee883eadd
parent6cadf1226004f2f2d91403c8bc81ca975a77ca52 (diff)
downloadmatterbridge-msglm-1a4717b366a2371dacc0ce205b0a42c5b31f52dc.tar.gz
matterbridge-msglm-1a4717b366a2371dacc0ce205b0a42c5b31f52dc.tar.bz2
matterbridge-msglm-1a4717b366a2371dacc0ce205b0a42c5b31f52dc.zip
Reject cross-channel message references (discord) (#1345)
Discord message references have been designed in a way for this to support cross-channel or even cross-guild references in the future. This will ensure the ParentID is *not* set when the message refers to a message that was sent in a different channel.
-rw-r--r--bridge/discord/handlers.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go
index d2b38538..81a0e11c 100644
--- a/bridge/discord/handlers.go
+++ b/bridge/discord/handlers.go
@@ -127,9 +127,9 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
// Replace emotes
rmsg.Text = replaceEmotes(rmsg.Text)
- // Add our parent id if it exists
- if m.MessageReference != nil {
- rmsg.ParentID = m.MessageReference.MessageID
+ // Add our parent id if it exists, and if it's not referring to a message in another channel
+ if ref := m.MessageReference; ref != nil && ref.ChannelID == m.ChannelID {
+ rmsg.ParentID = ref.MessageID
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)