From a3e7fba56fc88371ef9b41ae490783729a705023 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 8 Jan 2011 23:15:27 +0000 Subject: util.pubsub: Some tidying/optimisation to service:may() --- util/pubsub.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/util/pubsub.lua b/util/pubsub.lua index 3beafab5..97611d00 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -27,17 +27,14 @@ end function service:may(node, actor, action) if actor == true then return true; end - local node_obj = self.nodes[node]; local node_aff = node_obj and node_obj.affiliations[actor]; local service_aff = self.affiliations[actor] or self.config.get_affiliation(actor, node, action) or "none"; + -- Check if node allows/forbids it local node_capabilities = node_obj and node_obj.capabilities; - local service_capabilities = self.config.capabilities; - - -- Check if node allows/forbids it if node_capabilities then local caps = node_capabilities[node_aff or service_aff]; if caps then @@ -47,7 +44,9 @@ function service:may(node, actor, action) end end end + -- Check service-wide capabilities instead + local service_capabilities = self.config.capabilities; local caps = service_capabilities[node_aff or service_aff]; if caps then local can = caps[action]; -- cgit v1.2.3