Diff

plugins/mod_presence.lua @ 1477:e0411d6c9bae

mod_presence: Broadcast presence to resources before contacts
author Waqas Hussain <waqas20@gmail.com>
date Sun, 05 Jul 2009 12:43:25 +0500
parent 1476:5d6199a9b4f6
child 1479:eef17ebe3ca1
line wrap: on
line diff
--- a/plugins/mod_presence.lua	Sun Jul 05 12:40:18 2009 +0500
+++ b/plugins/mod_presence.lua	Sun Jul 05 12:43:25 2009 +0500
@@ -62,12 +62,6 @@
 
 function handle_normal_presence(origin, stanza, core_route_stanza)
 	local roster = origin.roster;
-	for jid, item in pairs(roster) do -- broadcast to all interested contacts
-		if item.subscription == "both" or item.subscription == "from" then
-			stanza.attr.to = jid;
-			core_route_stanza(origin, stanza);
-		end
-	end
 	local node, host = origin.username, origin.host;
 	for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources
 		if res ~= origin and res.presence then -- to resource
@@ -75,6 +69,12 @@
 			core_route_stanza(origin, stanza);
 		end
 	end
+	for jid, item in pairs(roster) do -- broadcast to all interested contacts
+		if item.subscription == "both" or item.subscription == "from" then
+			stanza.attr.to = jid;
+			core_route_stanza(origin, stanza);
+		end
+	end
 	if stanza.attr.type == nil and not origin.presence then -- initial presence
 		local probe = st.presence({from = origin.full_jid, type = "probe"});
 		for jid, item in pairs(roster) do -- probe all contacts we are subscribed to