aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-01-08 23:15:27 +0000
committerMatthew Wild <mwild1@gmail.com>2011-01-08 23:15:27 +0000
commita3e7fba56fc88371ef9b41ae490783729a705023 (patch)
tree325ca7da09fb19be9805429bc129ac661bc6bf98 /util
parent4d3ece9c60d35b11e47daf5e93cf6072e5ba93f6 (diff)
downloadprosody-a3e7fba56fc88371ef9b41ae490783729a705023.tar.gz
prosody-a3e7fba56fc88371ef9b41ae490783729a705023.zip
util.pubsub: Some tidying/optimisation to service:may()
Diffstat (limited to 'util')
-rw-r--r--util/pubsub.lua7
1 files 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];