Changeset

4100:69e3f1e7111e

util.pubsub: Pass true instead of nil as the actor in a bunch of places, and fix a bunch of methods to not traceback on this (those with *_other capability checking).
author Matthew Wild <mwild1@gmail.com>
date Sat, 08 Jan 2011 23:17:17 +0000
parents 4099:5c0b7947f0ef
children 4104:582ba9c459ad
files util/pubsub.lua
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/util/pubsub.lua	Sat Jan 08 23:15:27 2011 +0000
+++ b/util/pubsub.lua	Sat Jan 08 23:17:17 2011 +0000
@@ -69,14 +69,14 @@
 		return false, "item-not-found";
 	end
 	node_obj.affiliations[jid] = affiliation;
-	local _, jid_sub = self:get_subscription(node, nil, jid);
+	local _, jid_sub = self:get_subscription(node, true, jid);
 	if not jid_sub and not self:may(node, jid, "be_unsubscribed") then
-		local ok, err = self:add_subscription(node, nil, jid);
+		local ok, err = self:add_subscription(node, true, jid);
 		if not ok then
 			return ok, err;
 		end
 	elseif jid_sub and not self:may(node, jid, "be_subscribed") then
-		local ok, err = self:add_subscription(node, nil, jid);
+		local ok, err = self:add_subscription(node, true, jid);
 		if not ok then
 			return ok, err;
 		end
@@ -87,7 +87,7 @@
 function service:add_subscription(node, actor, jid, options)
 	-- Access checking
 	local cap;
-	if jid == actor or self:jids_equal(actor, jid) then
+	if actor == true or jid == actor or self:jids_equal(actor, jid) then
 		cap = "subscribe";
 	else
 		cap = "subscribe_other";
@@ -129,7 +129,7 @@
 function service:remove_subscription(node, actor, jid)
 	-- Access checking
 	local cap;
-	if jid == actor or self:jids_equal(actor, jid) then
+	if actor == true or jid == actor or self:jids_equal(actor, jid) then
 		cap = "unsubscribe";
 	else
 		cap = "unsubscribe_other";
@@ -169,7 +169,7 @@
 function service:get_subscription(node, actor, jid)
 	-- Access checking
 	local cap;
-	if jid == actor or self:jids_equal(actor, jid) then
+	if actor == true or jid == actor or self:jids_equal(actor, jid) then
 		cap = "get_subscription";
 	else
 		cap = "get_subscription_other";
@@ -277,7 +277,7 @@
 function service:get_subscriptions(node, actor, jid)
 	-- Access checking
 	local cap;
-	if jid == actor or self:jids_equal(actor, jid) then
+	if actor == true or jid == actor or self:jids_equal(actor, jid) then
 		cap = "get_subscriptions";
 	else
 		cap = "get_subscriptions_other";