Changeset

1474:6947761fd531

mod_presence: Simplified roster iteration
author Waqas Hussain <waqas20@gmail.com>
date Sun, 05 Jul 2009 12:17:22 +0500
parents 1473:d2211cbb822f
children 1475:16c8b1a8f6a7
files plugins/mod_presence.lua
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_presence.lua	Sun Jul 05 11:59:51 2009 +0500
+++ b/plugins/mod_presence.lua	Sun Jul 05 12:17:22 2009 +0500
@@ -62,9 +62,8 @@
 
 function handle_normal_presence(origin, stanza, core_route_stanza)
 	if origin.roster then
-		for jid in pairs(origin.roster) do -- broadcast to all interested contacts
-			local subscription = origin.roster[jid].subscription;
-			if subscription == "both" or subscription == "from" then
+		for jid, item in pairs(origin.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
@@ -78,9 +77,8 @@
 		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 in pairs(origin.roster) do -- probe all contacts we are subscribed to
-				local subscription = origin.roster[jid].subscription;
-				if subscription == "both" or subscription == "to" then
+			for jid, item in pairs(origin.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);
 				end