Comparison

core/rostermanager.lua @ 9303:72f0862978ef

rostermanager: Use util.id to generate ids for roster pushed
author Matthew Wild <mwild1@gmail.com>
date Thu, 13 Sep 2018 16:08:38 +0100
parent 8717:9ddd0fbbe53a
child 9671:e50559a42dfe
child 10569:fdc2bae50100
comparison
equal deleted inserted replaced
9302:57f8e41255fb 9303:72f0862978ef
8 -- luacheck: globals prosody.bare_sessions.?.roster 8 -- luacheck: globals prosody.bare_sessions.?.roster
9 9
10 10
11 11
12 local log = require "util.logger".init("rostermanager"); 12 local log = require "util.logger".init("rostermanager");
13
14 local new_id = require "util.id".short;
13 15
14 local pairs = pairs; 16 local pairs = pairs;
15 local tostring = tostring; 17 local tostring = tostring;
16 local type = type; 18 local type = type;
17 19
59 61
60 local function roster_push(username, host, jid) 62 local function roster_push(username, host, jid)
61 local roster = jid and hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster; 63 local roster = jid and hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster;
62 if roster then 64 if roster then
63 local item = hosts[host].sessions[username].roster[jid]; 65 local item = hosts[host].sessions[username].roster[jid];
64 local stanza = st.iq({type="set"}); 66 local stanza = st.iq({type="set", id=new_id()});
65 stanza:tag("query", {xmlns = "jabber:iq:roster", ver = tostring(roster[false].version or "1") }); 67 stanza:tag("query", {xmlns = "jabber:iq:roster", ver = tostring(roster[false].version or "1") });
66 if item then 68 if item then
67 stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name, ask = item.ask}); 69 stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name, ask = item.ask});
68 for group in pairs(item.groups) do 70 for group in pairs(item.groups) do
69 stanza:tag("group"):text(group):up(); 71 stanza:tag("group"):text(group):up();