mirror of
https://github.com/bjc/prosody.git
synced 2025-04-05 06:07:37 +03:00
mod_roster: Tidier code for the roster versioning logic
This commit is contained in:
parent
c4bb05ab3e
commit
edc283b455
1 changed files with 4 additions and 3 deletions
|
@ -36,9 +36,10 @@ module:add_iq_handler("c2s", "jabber:iq:roster",
|
||||||
if stanza.attr.type == "get" then
|
if stanza.attr.type == "get" then
|
||||||
local roster = st.reply(stanza);
|
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");
|
roster:query("jabber:iq:roster");
|
||||||
-- Client does not support versioning, or has stale roster
|
-- Client does not support versioning, or has stale roster
|
||||||
for jid in pairs(session.roster) do
|
for jid in pairs(session.roster) do
|
||||||
|
@ -55,7 +56,7 @@ module:add_iq_handler("c2s", "jabber:iq:roster",
|
||||||
roster:up(); -- move out from item
|
roster:up(); -- move out from item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
roster.tags[1].attr.ver = tostring(session.roster[false].version or "1");
|
roster.tags[1].attr.ver = server_ver;
|
||||||
end
|
end
|
||||||
session.send(roster);
|
session.send(roster);
|
||||||
session.interested = true; -- resource is interested in roster updates
|
session.interested = true; -- resource is interested in roster updates
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue