diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-12-21 06:25:12 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-12-21 06:25:12 +0500 |
commit | 0453ec49b81705e71558828c349dafd4745c8dc3 (patch) | |
tree | a0af014d76e512eecdb33ce55562bf7e6e736350 /plugins | |
parent | 90a40596380e94c8e47531db4dbf139ae5e836b7 (diff) | |
download | prosody-0453ec49b81705e71558828c349dafd4745c8dc3.tar.gz prosody-0453ec49b81705e71558828c349dafd4745c8dc3.zip |
mod_disco: Handle and fire events for service discovery queries for bare account JIDs (thanks darkrain).
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_disco.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/mod_disco.lua b/plugins/mod_disco.lua index 06b29f0e..a96472c4 100644 --- a/plugins/mod_disco.lua +++ b/plugins/mod_disco.lua @@ -7,6 +7,9 @@ -- local componentmanager_get_children = require "core.componentmanager".get_children; +local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; +local jid_split = require "util.jid".split; +local jid_bare = require "util.jid".bare; local st = require "util.stanza" module:add_identity("server", "im", "Prosody"); -- FIXME should be in the non-existing mod_router @@ -50,3 +53,31 @@ module:hook("iq/host/http://jabber.org/protocol/disco#items:query", function(eve origin.send(reply); return true; end); +module:hook("iq/bare/http://jabber.org/protocol/disco#info:query", function(event) + local origin, stanza = event.origin, event.stanza; + if stanza.attr.type ~= "get" then return; end + local node = stanza.tags[1].attr.node; + if node and node ~= "" then return; end -- TODO fire event? + local username = jid_split(stanza.attr.to) or origin.username; + if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then + local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info'}); + if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account + module:fire_event("account-disco-info", { session = origin, stanza = reply }); + origin.send(reply); + return true; + end +end); +module:hook("iq/bare/http://jabber.org/protocol/disco#items:query", function(event) + local origin, stanza = event.origin, event.stanza; + if stanza.attr.type ~= "get" then return; end + local node = stanza.tags[1].attr.node; + if node and node ~= "" then return; end -- TODO fire event? + local username = jid_split(stanza.attr.to) or origin.username; + if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then + local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#items'}); + if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account + module:fire_event("account-disco-items", { session = origin, stanza = reply }); + origin.send(reply); + return true; + end +end); |