Diff

plugins/mod_roster.lua @ 2908:4d9a73abb237

mod_roster: Tidier code for the roster versioning logic
author Matthew Wild <mwild1@gmail.com>
date Mon, 22 Mar 2010 01:54:22 +0000
parent 2611:c3ea4d3f857f
child 2925:692b3c6c5bd2
line wrap: on
line diff
--- a/plugins/mod_roster.lua	Sat Mar 20 14:16:33 2010 +0000
+++ b/plugins/mod_roster.lua	Mon Mar 22 01:54:22 2010 +0000
@@ -36,9 +36,10 @@
 				if stanza.attr.type == "get" then
 					local roster = st.reply(stanza);
 					
-					local ver = stanza.tags[1].attr.ver
+					local client_ver = tonumber(stanza.tags[1].attr.ver);
+					local server_ver = tonumber(session.roster[false].version or 1);
 					
-					if (not ver) or tonumber(ver) ~= (session.roster[false].version or 1) then
+					if not (client_ver and server_ver) or client_ver ~= server_ver then
 						roster:query("jabber:iq:roster");
 						-- Client does not support versioning, or has stale roster
 						for jid in pairs(session.roster) do
@@ -55,7 +56,7 @@
 								roster:up(); -- move out from item
 							end
 						end
-						roster.tags[1].attr.ver = tostring(session.roster[false].version or "1");
+						roster.tags[1].attr.ver = server_ver;
 					end
 					session.send(roster);
 					session.interested = true; -- resource is interested in roster updates