From 7fbca825f85a0936487d0b780dc53dcdbb920e21 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 9 Mar 2019 08:19:45 -0800 Subject: [PATCH] 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) --- disco/types/channel.py | 9 ++------- disco/types/permissions.py | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/disco/types/channel.py b/disco/types/channel.py index 0ef5f7a..3e84a9e 100644 --- a/disco/types/channel.py +++ b/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: diff --git a/disco/types/permissions.py b/disco/types/permissions.py index 6157bd9..d11b08f 100644 --- a/disco/types/permissions.py +++ b/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: