Comparison

plugins/mod_roster.lua @ 30:bcf539295f2d

Huge commit to: * Break stanza routing (to be restored in a future commit) * Remove the old stanza_dispatcher code, which was never going to be maintainable nor extendable :) * Bring us plugins, starting with mod_legacyauth and mod_roster * Sessions are now created/destroyed using a standard sessionmanager interface
author Matthew Wild <mwild1@gmail.com>
date Tue, 30 Sep 2008 19:52:00 +0100
child 79:2766e23c4d7d
comparison
equal deleted inserted replaced
29:b847875801e5 30:bcf539295f2d
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);