mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 08:44:10 +00:00
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.
This commit is contained in:
parent
bca6b2a133
commit
26f5bcd725
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user