30
|
1
|
|
2 local st = require "util.stanza"
|
|
3 local send = require "core.sessionmanager".send_to_session
|
|
4
|
|
5 add_iq_handler("c2s", "jabber:iq:roster",
|
|
6 function (session, stanza)
|
|
7 if stanza.attr.type == "get" then
|
|
8 session.roster = session.roster or rostermanager.getroster(session.username, session.host);
|
|
9 if session.roster == false then
|
|
10 send(session, st.reply(stanza)
|
|
11 :tag("error", { type = "wait" })
|
|
12 :tag("internal-server-error", { xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}));
|
|
13 return true;
|
|
14 else session.roster = session.roster or {};
|
|
15 end
|
|
16 local roster = st.reply(stanza)
|
|
17 :query("jabber:iq:roster");
|
|
18 for jid in pairs(session.roster) do
|
|
19 roster:tag("item", { jid = jid, subscription = "none" }):up();
|
|
20 end
|
|
21 send(session, roster);
|
|
22 return true;
|
|
23 end
|
|
24 end); |