Changeset

5059:246ba539a5cd

mod_component: For disconnected external components, if a name is specified in config, return it in disco#info replies.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 01 Aug 2012 01:36:13 +0500
parents 5058:433cc9a4c7e9
children 5060:b0e36777f715
files plugins/mod_component.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_component.lua	Wed Aug 01 01:36:11 2012 +0500
+++ b/plugins/mod_component.lua	Wed Aug 01 01:36:13 2012 +0500
@@ -93,6 +93,18 @@
 			stanza.attr.xmlns = nil;
 			send(stanza);
 		else
+			if stanza.name == "iq" and stanza.attr.type == "get" and stanza.attr.to == module.host then
+				local query = stanza.tags[1];
+				local node = query.attr.node;
+				if query.name == "query" and query.attr.xmlns == "http://jabber.org/protocol/disco#info" and (not node or node == "") then
+					local name = module:get_option_string("name");
+					if name then
+						event.origin.send(st.reply(stanza):tag("query", { xmlns = "http://jabber.org/protocol/disco#info" })
+							:tag("identity", { category = "component", type = "generic", name = module:get_option_string("name", "Prosody") }))
+						return true;
+					end
+				end
+			end
 			module:log("warn", "Component not connected, bouncing error for: %s", stanza:top_tag());
 			if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
 				event.origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable"));