mod_presence: Handle subscriptions and probes

Tue, 02 Jun 2009 16:06:02 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Tue, 02 Jun 2009 16:06:02 +0500
changeset 1282
ff58ef687a3f
parent 1281
bc65d57c76ef
child 1283
2e57f2176612

mod_presence: Handle subscriptions and probes

plugins/mod_presence.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_presence.lua	Tue Jun 02 15:59:03 2009 +0500
+++ b/plugins/mod_presence.lua	Tue Jun 02 16:06:02 2009 +0500
@@ -273,11 +273,11 @@
 end
 
 local outbound_presence_handler = function(data)
-	-- outbound presence to recieved
+	-- outbound presence recieved
 	local origin, stanza = data.origin, data.stanza;
 
 	local t = stanza.attr.type;
-	if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID
+	if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes
 		handle_outbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);
 		return true;
 	end
@@ -301,8 +301,20 @@
 module:hook("presence/bare", function(data)
 	-- inbound presence to bare JID recieved
 	local origin, stanza = data.origin, data.stanza;
+
+	local t = stanza.attr.type;
+	if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to bare JID
+		handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);
+		return true;
+	end
 end);
 module:hook("presence/full", function(data)
 	-- inbound presence to full JID recieved
 	local origin, stanza = data.origin, data.stanza;
+
+	local t = stanza.attr.type;
+	if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID
+		handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);
+		return true;
+	end
 end);

mercurial