Comparison

plugins/mod_roster.lua @ 1198:545c81364939

mod_roster: Don't send a query element in roster response if roster is unchanged
author Matthew Wild <mwild1@gmail.com>
date Tue, 26 May 2009 01:07:21 +0100
parent 1133:b293d7dc6a45
child 1200:57a72472e1bc
comparison
equal deleted inserted replaced
1197:1f4a4e6ae694 1198:545c81364939
33 33
34 module:add_iq_handler("c2s", "jabber:iq:roster", 34 module:add_iq_handler("c2s", "jabber:iq:roster",
35 function (session, stanza) 35 function (session, stanza)
36 if stanza.tags[1].name == "query" then 36 if stanza.tags[1].name == "query" then
37 if stanza.attr.type == "get" then 37 if stanza.attr.type == "get" then
38 local roster = st.reply(stanza) 38 local roster = st.reply(stanza);
39 :query("jabber:iq:roster");
40 39
41 local ver = stanza.tags[1].attr.ver 40 local ver = stanza.tags[1].attr.ver
42 41
43 if (not ver) or tonumber(ver) ~= (session.roster[false].version or 1) then 42 if (not ver) or tonumber(ver) ~= (session.roster[false].version or 1) then
43 roster:query("jabber:iq:roster");
44 -- Client does not support versioning, or has stale roster 44 -- Client does not support versioning, or has stale roster
45 for jid in pairs(session.roster) do 45 for jid in pairs(session.roster) do
46 if jid ~= "pending" and jid then 46 if jid ~= "pending" and jid then
47 roster:tag("item", { 47 roster:tag("item", {
48 jid = jid, 48 jid = jid,