diff options
author | Qais Patankar <qaisjp@gmail.com> | 2020-03-17 16:04:38 +0000 |
---|---|---|
committer | Wim <wim@42.be> | 2020-03-18 23:10:47 +0100 |
commit | b5dc4353fbecb90b74139c1aea8ae88b24f2fd0e (patch) | |
tree | d2c828450fac97b3bcf89fe00604d52ff8ceebb1 /bridge/discord/discord.go | |
parent | 2fbac73c2998cb5e84e6d54eaa780221b8178b45 (diff) | |
download | matterbridge-msglm-b5dc4353fbecb90b74139c1aea8ae88b24f2fd0e.tar.gz matterbridge-msglm-b5dc4353fbecb90b74139c1aea8ae88b24f2fd0e.tar.bz2 matterbridge-msglm-b5dc4353fbecb90b74139c1aea8ae88b24f2fd0e.zip |
Fix #1040: spotty webhook permission verification
Diffstat (limited to 'bridge/discord/discord.go')
-rw-r--r-- | bridge/discord/discord.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index c0817911..7661a1da 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -114,10 +114,10 @@ func (b *Bdiscord) Connect() error { b.Log.Infof("Server=\"%s\" # Server ID", guild.ID) } } - if err != nil { return err } + b.channelsMutex.RLock() if b.GetString("WebhookURL") == "" { for _, channel := range b.channels { @@ -128,9 +128,13 @@ func (b *Bdiscord) Connect() error { 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) + perms, permsErr := b.c.UserChannelPermissions(userinfo.ID, id) + manageWebhooks := discordgo.PermissionManageWebhooks - if permsErr != nil || perms&manageWebhooks != manageWebhooks { + if permsErr != nil { + b.Log.Warnf("Can't manage webhooks in channel \"%s\", because: %s", info.Name, permsErr.Error()) + b.canEditWebhooks = false + } else if perms&manageWebhooks != manageWebhooks { b.Log.Warnf("Can't manage webhooks in channel \"%s\"", info.Name) b.canEditWebhooks = false } |