Skip to content

Commit

Permalink
Check only bridged channels for PermManageWebhooks (discord) (#1001)
Browse files Browse the repository at this point in the history
* Check only bridged channels for PermManageWebhooks

* add note
  • Loading branch information
qaisjp authored Feb 8, 2020
1 parent c0be3e5 commit 1420f68
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bridge/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) // 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
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
}
}
Expand Down

0 comments on commit 1420f68

Please sign in to comment.