diff options
| author | Rapptz <[email protected]> | 2016-09-10 16:11:52 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-09-10 16:11:52 -0400 |
| commit | 26f5bcd725894926d0d839514cc1b69556f505a6 (patch) | |
| tree | c998971fb22e1c5725220f126c914a65df28e97f | |
| parent | Fix bug that disallowed ServerRegion from being used in edit_server. (diff) | |
| download | discord.py-26f5bcd725894926d0d839514cc1b69556f505a6.tar.xz discord.py-26f5bcd725894926d0d839514cc1b69556f505a6.zip | |
Fix bug when permission overwrites could be applied out of order.
The bug was due to the fact that the way overwrites work is by doing
a loop of all the values and then applying deny first and then allow.
That way the overwrite is defined if role A and role B deny a
permission but role C allows it (and said member has A, B, C roles)
then the resolution should allow it rather than deny it regardless of
the order of the data it is received in.
| -rw-r--r-- | discord/channel.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/discord/channel.py b/discord/channel.py index b6f491ce..54d90d44 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -245,16 +245,22 @@ class Channel(Hashable): return Permissions.all() member_role_ids = set(map(lambda r: r.id, member.roles)) + denies = 0 + allows = 0 # Apply channel specific role permission overwrites for overwrite in self._permission_overwrites: if overwrite.type == 'role' and overwrite.id in member_role_ids: - base.handle_overwrite(allow=overwrite.allow, deny=overwrite.deny) + denies |= overwrite.deny + allows |= overwrite.allow + + base.handle_overwrite(allow=allows, deny=denies) # Apply member specific permission overwrites for overwrite in self._permission_overwrites: if overwrite.type == 'member' and overwrite.id == member.id: base.handle_overwrite(allow=overwrite.allow, deny=overwrite.deny) + break # default channels can always be read if self.is_default: |