util.pubsub: Add service:jids_equal() and new config option normalize_jid

Wed, 22 Dec 2010 03:04:14 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 22 Dec 2010 03:04:14 +0000
changeset 3934
4bd994df7296
parent 3933
24f0a7544a7a
child 3935
2733b56f23b0

util.pubsub: Add service:jids_equal() and new config option normalize_jid

util/pubsub.lua file | annotate | diff | comparison | revisions
--- a/util/pubsub.lua	Wed Dec 22 02:19:14 2010 +0000
+++ b/util/pubsub.lua	Wed Dec 22 03:04:14 2010 +0000
@@ -18,6 +18,11 @@
 	}, service_mt);
 end
 
+function service:jids_equal(jid1, jid2)
+	local normalize = self.config.normalize_jid;
+	return normalize(jid1) == normalize(jid2);
+end
+
 function service:may(node, actor, action)
 	if actor == true then return true; end
 	
@@ -82,7 +87,7 @@
 function service:add_subscription(node, actor, jid, options)
 	-- Access checking
 	local cap;
-	if jid == actor or self.config.jids_equal(actor, jid) then
+	if jid == actor or self:jids_equal(actor, jid) then
 		cap = "subscribe";
 	else
 		cap = "subscribe_other";
@@ -112,7 +117,7 @@
 function service:remove_subscription(node, actor, jid)
 	-- Access checking
 	local cap;
-	if jid == actor or self.config.jids_equal(actor, jid) then
+	if jid == actor or self:jids_equal(actor, jid) then
 		cap = "unsubscribe";
 	else
 		cap = "unsubscribe_other";
@@ -138,7 +143,7 @@
 function service:get_subscription(node, actor, jid)
 	-- Access checking
 	local cap;
-	if jid == actor or self.config.jids_equal(actor, jid) then
+	if jid == actor or self:jids_equal(actor, jid) then
 		cap = "get_subscription";
 	else
 		cap = "get_subscription_other";

mercurial