Software /
code /
prosody
Changeset
4099:5c0b7947f0ef
util.pubsub: Some tidying/optimisation to service:may()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 08 Jan 2011 23:15:27 +0000 |
parents | 4098:7d687c348295 |
children | 4100:69e3f1e7111e |
files | util/pubsub.lua |
diffstat | 1 files changed, 3 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/util/pubsub.lua Sat Jan 08 09:09:19 2011 +0100 +++ b/util/pubsub.lua Sat Jan 08 23:15:27 2011 +0000 @@ -27,17 +27,14 @@ 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 @@ 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];