mod_pubsub: Implement disco#info for nodes

Wed, 22 Dec 2010 16:53:38 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 22 Dec 2010 16:53:38 +0000
changeset 3944
74a422abec11
parent 3943
ad5924c31953
child 3945
39e34cb4c491

mod_pubsub: Implement disco#info for nodes

plugins/mod_pubsub.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_pubsub.lua	Wed Dec 22 16:46:19 2010 +0000
+++ b/plugins/mod_pubsub.lua	Wed Dec 22 16:53:38 2010 +0000
@@ -231,8 +231,23 @@
 end
 
 module:hook("iq-get/host/http://jabber.org/protocol/disco#info:query", function (event)
-	event.origin.send(st.reply(event.stanza):add_child(disco_info));
-	return true;
+	local origin, stanza = event.origin, event.stanza;
+	local node = stanza.tags[1].attr.node;
+	if not node then
+		return origin.send(st.reply(stanza):add_child(disco_info));
+	else
+		local ok, ret = service:get_nodes(stanza.attr.from);
+		if ok and not ret[node] then
+			ok, ret = false, "item-not-found";
+		end
+		if not ok then
+			return origin.send(pubsub_error_reply(stanza, ret));
+		end
+		local reply = st.reply(stanza)
+			:tag("query", { xmlns = "http://jabber.org/protocol/disco#info", node = node })
+				:tag("identity", { category = "pubsub", type = "leaf" });
+		return origin.send(reply);
+	end
 end);
 
 local function handle_disco_items_on_node(event)

mercurial