From 99e51ba9cdc0b49501094aa6b8bb1bab5d6ce377 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 22 Dec 2010 02:17:45 +0000 Subject: mod_pubsub: Handle disco#items on nodes --- plugins/mod_pubsub.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'plugins/mod_pubsub.lua') 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)); -- cgit v1.2.3