mod_presence: Changed handle_normal_presence to use a local roster rather than origin's roster

Sun, 05 Jul 2009 12:25:15 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sun, 05 Jul 2009 12:25:15 +0500
changeset 1475
16c8b1a8f6a7
parent 1474
6947761fd531
child 1476
5d6199a9b4f6

mod_presence: Changed handle_normal_presence to use a local roster rather than origin's roster

plugins/mod_presence.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_presence.lua	Sun Jul 05 12:17:22 2009 +0500
+++ b/plugins/mod_presence.lua	Sun Jul 05 12:25:15 2009 +0500
@@ -61,8 +61,9 @@
 end
 
 function handle_normal_presence(origin, stanza, core_route_stanza)
-	if origin.roster then
-		for jid, item in pairs(origin.roster) do -- broadcast to all interested contacts
+	local roster = origin.roster;
+	if roster then
+		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);
@@ -77,7 +78,7 @@
 		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(origin.roster) do -- probe all contacts we are subscribed to
+			for jid, item in pairs(roster) do -- probe all contacts we are subscribed to
 				if item.subscription == "both" or item.subscription == "to" then
 					probe.attr.to = jid;
 					core_route_stanza(origin, probe);
@@ -90,13 +91,13 @@
 					res.presence.attr.to = nil;
 				end
 			end
-			if origin.roster.pending then -- resend incoming subscription requests
-				for jid in pairs(origin.roster.pending) do
+			if roster.pending then -- resend incoming subscription requests
+				for jid in pairs(roster.pending) do
 					origin.send(st.presence({type="subscribe", from=jid})); -- TODO add to attribute? Use original?
 				end
 			end
 			local request = st.presence({type="subscribe", from=origin.username.."@"..origin.host});
-			for jid, item in pairs(origin.roster) do -- resend outgoing subscription requests
+			for jid, item in pairs(roster) do -- resend outgoing subscription requests
 				if item.ask then
 					request.attr.to = jid;
 					core_route_stanza(origin, request);

mercurial