mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-22 19:22:38 +01:00
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.
This commit is contained in:
parent
6cadf12260
commit
1a4717b366
@ -127,9 +127,9 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
|
|||||||
// Replace emotes
|
// Replace emotes
|
||||||
rmsg.Text = replaceEmotes(rmsg.Text)
|
rmsg.Text = replaceEmotes(rmsg.Text)
|
||||||
|
|
||||||
// Add our parent id if it exists
|
// Add our parent id if it exists, and if it's not referring to a message in another channel
|
||||||
if m.MessageReference != nil {
|
if ref := m.MessageReference; ref != nil && ref.ChannelID == m.ChannelID {
|
||||||
rmsg.ParentID = m.MessageReference.MessageID
|
rmsg.ParentID = ref.MessageID
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)
|
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)
|
||||||
|
Loading…
Reference in New Issue
Block a user