diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-12-22 02:17:45 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-12-22 02:17:45 +0000 |
commit | 99e51ba9cdc0b49501094aa6b8bb1bab5d6ce377 (patch) | |
tree | 109bd73e0e7fa6de5401cd0654537ff18c5a43b4 /plugins/mod_pubsub.lua | |
parent | df0acaf9855de1de4d433f0a300e6e856f60d3e8 (diff) | |
download | prosody-99e51ba9cdc0b49501094aa6b8bb1bab5d6ce377.tar.gz prosody-99e51ba9cdc0b49501094aa6b8bb1bab5d6ce377.zip |
mod_pubsub: Handle disco#items on nodes
Diffstat (limited to 'plugins/mod_pubsub.lua')
-rw-r--r-- | plugins/mod_pubsub.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 841de147..ecb5115a 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -219,7 +219,30 @@ module:hook("iq-get/host/http://jabber.org/protocol/disco#info:query", function return true; end); +local function handle_disco_items_on_node(event) + local stanza, origin = event.stanza, event.origin; + local query = stanza.tags[1]; + local node = query.attr.node; + local ok, ret = service:get_items(node, stanza.attr.from); + if not ok then + return origin.send(pubsub_error_reply(stanza, ret)); + end + + local reply = st.reply(stanza) + :tag("query", { xmlns = xmlns_disco_items }); + + for id, item in pairs(ret) do + reply:tag("item", { jid = module.host, name = id }); + end + + return origin.send(reply); +end + + module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function (event) + if event.stanza.tags[1].attr.node then + return handle_disco_items_on_node(event); + end local ok, ret = service:get_nodes(event.stanza.attr.from); if not ok then event.origin.send(pubsub_error_reply(stanza, ret)); |