aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_roster.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mod_roster.lua')
-rw-r--r--plugins/mod_roster.lua19
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/mod_roster.lua b/plugins/mod_roster.lua
index 755d263d..ddf02f2f 100644
--- a/plugins/mod_roster.lua
+++ b/plugins/mod_roster.lua
@@ -23,12 +23,12 @@ local core_post_stanza = core_post_stanza;
module:add_feature("jabber:iq:roster");
local rosterver_stream_feature = st.stanza("ver", {xmlns="urn:xmpp:features:rosterver"}):tag("optional"):up();
-module:add_event_hook("stream-features",
- function (session, features)
- if session.username then
- features:add_child(rosterver_stream_feature);
- end
- end);
+module:hook("stream-features", function(event)
+ local origin, features = event.origin, event.features;
+ if origin.username then
+ features:add_child(rosterver_stream_feature);
+ end
+end);
module:add_iq_handler("c2s", "jabber:iq:roster",
function (session, stanza)
@@ -36,9 +36,10 @@ module:add_iq_handler("c2s", "jabber:iq:roster",
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 @@ module:add_iq_handler("c2s", "jabber:iq:roster",
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