util.pubsub: Add service:set_node_capabilities()

Tue, 21 Dec 2010 15:26:37 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 21 Dec 2010 15:26:37 +0000
changeset 3928
4dfb345e33ec
parent 3927
1b57e83266f0
child 3929
7cb03d67101b

util.pubsub: Add service:set_node_capabilities()

util/pubsub.lua file | annotate | diff | comparison | revisions
--- a/util/pubsub.lua	Tue Dec 21 14:44:13 2010 +0000
+++ b/util/pubsub.lua	Tue Dec 21 15:26:37 2010 +0000
@@ -242,4 +242,19 @@
 	return true, self.nodes;
 end
 
+-- Access models only affect 'none' affiliation caps, service/default access level...
+function service:set_node_capabilities(node, actor, capabilities)
+	-- Access checking
+	if not self:may(node, actor, "configure") then
+		return false, "forbidden";
+	end
+	--
+	local node_obj = self.nodes[node];
+	if not node_obj then
+		return false, "item-not-found";
+	end
+	node_obj.capabilities = capabilities;
+	return true;
+end
+
 return _M;

mercurial