Changeset

3932:aa245e43b21e

mod_pubsub: Handle disco#items on nodes
author Matthew Wild <mwild1@gmail.com>
date Wed, 22 Dec 2010 02:17:45 +0000
parents 3931:6daed692264f
children 3933:24f0a7544a7a
files plugins/mod_pubsub.lua
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub.lua	Wed Dec 22 02:13:26 2010 +0000
+++ b/plugins/mod_pubsub.lua	Wed Dec 22 02:17:45 2010 +0000
@@ -219,7 +219,30 @@
 	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));