From 1763238891540d36d61bfb1f4b9f7dc15fd91de1 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Fri, 7 Feb 2020 13:56:40 +0000 Subject: [PATCH 1/2] Check only bridged channels for PermManageWebhooks --- bridge/discord/discord.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index d247b95183..ae50644d80 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -125,12 +125,13 @@ func (b *Bdiscord) Connect() error { } } else { b.canEditWebhooks = true - for _, channel := range b.channels { - b.Log.Debugf("found channel %#v; verifying PermissionManageWebhooks", channel) - perms, permsErr := b.c.State.UserChannelPermissions(userinfo.ID, channel.ID) + for _, info := range b.Channels { + id := b.getChannelID(info.Name) + b.Log.Debugf("Verifying PermissionManageWebhooks for %s with ID %s", info.ID, id) + perms, permsErr := b.c.State.UserChannelPermissions(userinfo.ID, id) manageWebhooks := discordgo.PermissionManageWebhooks if permsErr != nil || perms&manageWebhooks != manageWebhooks { - b.Log.Warnf("Can't manage webhooks in channel \"%s\"", channel.Name) + b.Log.Warnf("Can't manage webhooks in channel \"%s\"", info.Name) b.canEditWebhooks = false } } From d511be22c456c6ad30afb6f1056882a136f88be0 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Fri, 7 Feb 2020 14:26:23 +0000 Subject: [PATCH 2/2] add note --- bridge/discord/discord.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index ae50644d80..e81d0783e9 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -126,7 +126,7 @@ func (b *Bdiscord) Connect() error { } else { b.canEditWebhooks = true for _, info := range b.Channels { - id := b.getChannelID(info.Name) + id := b.getChannelID(info.Name) // note(qaisjp): this readlocks channelsMutex b.Log.Debugf("Verifying PermissionManageWebhooks for %s with ID %s", info.ID, id) perms, permsErr := b.c.State.UserChannelPermissions(userinfo.ID, id) manageWebhooks := discordgo.PermissionManageWebhooks