aboutsummaryrefslogtreecommitdiff
path: root/src/core_modules/channel_access.py
diff options
context:
space:
mode:
authorGravatar jesopo2020-01-24 16:26:53 +0000
committerGravatar jesopo2020-01-24 16:26:53 +0000
commitf51b06aae198231841ccbd2e2c19de3524856348 (patch)
tree1d2cf882f5e13d1c17918a563cd12fda3d21b0d7 /src/core_modules/channel_access.py
parentimplement "important" command spec pieces, esp. for channel perms (diff)
signature
check "channel" coming from command_spec.py parsing (check_mode, channel_access)
Diffstat (limited to 'src/core_modules/channel_access.py')
-rw-r--r--src/core_modules/channel_access.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/core_modules/channel_access.py b/src/core_modules/channel_access.py
index 5502db9f..6238fa1c 100644
--- a/src/core_modules/channel_access.py
+++ b/src/core_modules/channel_access.py
@@ -13,21 +13,22 @@ class Module(ModuleManager.BaseModule):
return (require_access in access or "*" in access) and identified
- def _command_check(self, event, target, require_access):
- if event["is_channel"]:
- if require_access:
- if self._has_channel_access(target, event["user"],
- require_access):
- return utils.consts.PERMISSION_FORCE_SUCCESS, None
- else:
- return (utils.consts.PERMISSION_ERROR,
+ def _command_check(self, event, channel, require_access):
+ if channel and require_access:
+ if self._has_channel_access(channel, event["user"],
+ require_access):
+ return utils.consts.PERMISSION_FORCE_SUCCESS, None
+ else:
+ return (utils.consts.PERMISSION_ERROR,
"You do not have permission to do this")
@utils.hook("preprocess.command")
def preprocess_command(self, event):
require_access = event["hook"].get_kwarg("require_access")
if require_access:
- return self._command_check(event, event["target"], require_access)
+ channel = event["kwargs"].get("channel",
+ event["target"] if event["is_channel"] else None)
+ return self._command_check(event, channel, require_access)
@utils.hook("check.command.channel-access")
def check_command(self, event):