From c204694247ccaeffb4842d260f5e1a5fe0b9fe1e Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Wed, 1 Aug 2012 01:36:13 +0500 Subject: mod_component: For disconnected external components, if a name is specified in config, return it in disco#info replies. --- plugins/mod_component.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'plugins/mod_component.lua') diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index 751de59b..cff54f61 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -93,6 +93,18 @@ function module.add_host(module) 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")); -- cgit v1.2.3