5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-24 18:25:40 +00:00

Check only bridged channels for PermManageWebhooks (discord) (#1001)

* Check only bridged channels for PermManageWebhooks

* add note
This commit is contained in:
Qais Patankar 2020-02-08 14:13:23 +00:00 committed by GitHub
parent c0be3e585a
commit 1420f68050

View File

@ -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
}
}