summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorQais Patankar <qaisjp@gmail.com>2019-06-16 00:15:18 +0100
committerWim <wim@42.be>2019-06-16 16:07:48 +0200
commit76c7b69e4e099dd80119f4ca1f2fac01aa2f31e6 (patch)
tree109aba86c988b5d412c4363ef9fd9772785cd06e /bridge
parenta5bd3c4dda4bcad22a7998af4be41374324182f9 (diff)
downloadmatterbridge-msglm-76c7b69e4e099dd80119f4ca1f2fac01aa2f31e6.tar.gz
matterbridge-msglm-76c7b69e4e099dd80119f4ca1f2fac01aa2f31e6.tar.bz2
matterbridge-msglm-76c7b69e4e099dd80119f4ca1f2fac01aa2f31e6.zip
Support bulk deletions (discord)
Diffstat (limited to 'bridge')
-rw-r--r--bridge/discord/discord.go1
-rw-r--r--bridge/discord/handlers.go21
2 files changed, 22 insertions, 0 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index 49dfe4bc..ea43bd20 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -75,6 +75,7 @@ func (b *Bdiscord) Connect() error {
b.c.AddHandler(b.memberUpdate)
b.c.AddHandler(b.messageUpdate)
b.c.AddHandler(b.messageDelete)
+ b.c.AddHandler(b.messageDeleteBulk)
b.c.AddHandler(b.memberAdd)
b.c.AddHandler(b.memberRemove)
err = b.c.Open()
diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go
index 85a36e1d..19e0ad6a 100644
--- a/bridge/discord/handlers.go
+++ b/bridge/discord/handlers.go
@@ -16,6 +16,27 @@ func (b *Bdiscord) messageDelete(s *discordgo.Session, m *discordgo.MessageDelet
b.Remote <- rmsg
}
+// TODO(qaisjp): if other bridges support bulk deletions, it could be fanned out centrally
+func (b *Bdiscord) messageDeleteBulk(s *discordgo.Session, m *discordgo.MessageDeleteBulk) { //nolint:unparam
+ for _, msgID := range m.Messages {
+ rmsg := config.Message{
+ Account: b.Account,
+ ID: msgID,
+ Event: config.EventMsgDelete,
+ Text: config.EventMsgDelete,
+ Channel: "ID:" + m.ChannelID,
+ }
+
+ if !b.useChannelID {
+ rmsg.Channel = b.getChannelName(m.ChannelID)
+ }
+
+ b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
+ b.Log.Debugf("<= Message is %#v", rmsg)
+ b.Remote <- rmsg
+ }
+}
+
func (b *Bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) { //nolint:unparam
if b.GetBool("EditDisable") {
return