Browse Source

Fixes to permission calculations (#123)

* channel: fix TypeError when calculating permission overrides (#98)

* permissions: fix inverted binary AND when removing a permission by value (#98)
pull/128/head
James Lu 6 years ago
committed by Andrei Zbikowski
parent
commit
7fbca825f8
  1. 9
      disco/types/channel.py
  2. 2
      disco/types/permissions.py

9
disco/types/channel.py

@ -168,16 +168,11 @@ class Channel(SlottedModel, Permissible):
base -= everyone.deny
base += everyone.allow
denies = 0
allows = 0
for role_id in member.roles:
overwrite = self.overwrites.get(role_id)
if overwrite:
denies |= overwrite.deny
allows |= overwrite.allow
base -= denies
base += allows
base -= overwrite.deny
base += overwrite.allow
ow_member = self.overwrites.get(member.user.id)
if ow_member:

2
disco/types/permissions.py

@ -66,7 +66,7 @@ class PermissionValue(object):
if isinstance(other, PermissionValue):
self.value &= ~other.value
elif isinstance(other, int):
self.value &= other
self.value &= ~other
elif isinstance(other, EnumAttr):
setattr(self, other.name, False)
else:

Loading…
Cancel
Save