Software / code / prosody
Comparison
plugins/mod_component.lua @ 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 |
| parent | 5013:ab693eea0869 |
| child | 5120:bcabea740c00 |
comparison
equal
deleted
inserted
replaced
| 5058:433cc9a4c7e9 | 5059:246ba539a5cd |
|---|---|
| 91 local stanza = event.stanza; | 91 local stanza = event.stanza; |
| 92 if send then | 92 if send then |
| 93 stanza.attr.xmlns = nil; | 93 stanza.attr.xmlns = nil; |
| 94 send(stanza); | 94 send(stanza); |
| 95 else | 95 else |
| 96 if stanza.name == "iq" and stanza.attr.type == "get" and stanza.attr.to == module.host then | |
| 97 local query = stanza.tags[1]; | |
| 98 local node = query.attr.node; | |
| 99 if query.name == "query" and query.attr.xmlns == "http://jabber.org/protocol/disco#info" and (not node or node == "") then | |
| 100 local name = module:get_option_string("name"); | |
| 101 if name then | |
| 102 event.origin.send(st.reply(stanza):tag("query", { xmlns = "http://jabber.org/protocol/disco#info" }) | |
| 103 :tag("identity", { category = "component", type = "generic", name = module:get_option_string("name", "Prosody") })) | |
| 104 return true; | |
| 105 end | |
| 106 end | |
| 107 end | |
| 96 module:log("warn", "Component not connected, bouncing error for: %s", stanza:top_tag()); | 108 module:log("warn", "Component not connected, bouncing error for: %s", stanza:top_tag()); |
| 97 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then | 109 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then |
| 98 event.origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); | 110 event.origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); |
| 99 end | 111 end |
| 100 end | 112 end |