aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_roster.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-09-30 19:52:00 +0100
committerMatthew Wild <mwild1@gmail.com>2008-09-30 19:52:00 +0100
commita53395e6b72ac0abad00123e1d07b3504f585e08 (patch)
treeabcdd55cfafbc477ea75067efd89b5845f4cad19 /plugins/mod_roster.lua
parent733c39e3dacf91f10fcb2f9501b6f0618a0b11fc (diff)
downloadprosody-a53395e6b72ac0abad00123e1d07b3504f585e08.tar.gz
prosody-a53395e6b72ac0abad00123e1d07b3504f585e08.zip
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
Diffstat (limited to 'plugins/mod_roster.lua')
-rw-r--r--plugins/mod_roster.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/mod_roster.lua b/plugins/mod_roster.lua
new file mode 100644
index 00000000..8b4a3a0a
--- /dev/null
+++ b/plugins/mod_roster.lua
@@ -0,0 +1,24 @@
+
+local st = require "util.stanza"
+local send = require "core.sessionmanager".send_to_session
+
+add_iq_handler("c2s", "jabber:iq:roster",
+ function (session, stanza)
+ if stanza.attr.type == "get" then
+ session.roster = session.roster or rostermanager.getroster(session.username, session.host);
+ if session.roster == false then
+ send(session, st.reply(stanza)
+ :tag("error", { type = "wait" })
+ :tag("internal-server-error", { xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}));
+ return true;
+ else session.roster = session.roster or {};
+ end
+ local roster = st.reply(stanza)
+ :query("jabber:iq:roster");
+ for jid in pairs(session.roster) do
+ roster:tag("item", { jid = jid, subscription = "none" }):up();
+ end
+ send(session, roster);
+ return true;
+ end
+ end); \ No newline at end of file