Directed presence

Thu, 25 Dec 2008 04:58:15 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Thu, 25 Dec 2008 04:58:15 +0500
changeset 641
658a2de74afc
parent 640
068130563311
child 642
0ae8584ba3e7

Directed presence

core/presencemanager.lua file | annotate | diff | comparison | revisions
core/stanza_router.lua file | annotate | diff | comparison | revisions
--- a/core/presencemanager.lua	Thu Dec 25 04:27:19 2008 +0500
+++ b/core/presencemanager.lua	Thu Dec 25 04:58:15 2008 +0500
@@ -103,7 +103,14 @@
 		end
 		origin.priority = 0;
 		if stanza.attr.type == "unavailable" then
-			origin.presence = nil;
+			origin.presence = nil;
+			if origin.directed then
+				for _, jid in ipairs(origin.directed) do
+					stanza.attr.to = jid;
+					core_route_stanza(origin, stanza);
+				end
+				origin.directed = nil;
+			end
 		else
 			origin.presence = stanza;
 			local priority = stanza:child_with_name("priority");
--- a/core/stanza_router.lua	Thu Dec 25 04:27:19 2008 +0500
+++ b/core/stanza_router.lua	Thu Dec 25 04:58:15 2008 +0500
@@ -110,6 +110,10 @@
 		elseif origin.type ~= "c2s" and stanza.name == "iq" and not resource then -- directed at bare JID
 			core_handle_stanza(origin, stanza);
 		else
+			if origin.type == "c2s" and stanza.name == "presence" and to ~= nil and not(origin.roster[to_bare] and (origin.roster[to_bare].subscription == "both" or origin.roster[to_bare].subscription == "from")) then
+				origin.directed = origin.directed or {};
+				t_insert(origin.directed, to); -- FIXME does it make more sense to add to_bare rather than to?
+			end
 			core_route_stanza(origin, stanza);
 		end
 	else

mercurial