Changeset

1283:2e57f2176612

mod_presence: Handle non-subscription presence and routing
author Waqas Hussain <waqas20@gmail.com>
date Tue, 02 Jun 2009 16:21:20 +0500
parents 1282:ff58ef687a3f
children 1284:c0fb8379696e
files plugins/mod_presence.lua
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_presence.lua	Tue Jun 02 16:06:02 2009 +0500
+++ b/plugins/mod_presence.lua	Tue Jun 02 16:21:20 2009 +0500
@@ -307,6 +307,20 @@
 		handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);
 		return true;
 	end
+	
+	local to = stanza.attr.to;
+	if to then
+		local user = bare_sessions[to];
+		if user then
+			for _, session in pairs(user.sessions) do
+				if session.presence then -- only send to available resources
+					session.send(stanza);
+				end
+			end
+		end -- no resources not online, discard
+	else
+		handle_normal_presence(origin, stanza, core_route_stanza);
+	end
 end);
 module:hook("presence/full", function(data)
 	-- inbound presence to full JID recieved
@@ -317,4 +331,10 @@
 		handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);
 		return true;
 	end
+
+	local session = full_sessions[stanza.attr.to];
+	if session then
+		-- TODO fire post processing event
+		session.send(stanza);
+	end -- resource not online, discard
 end);