mod_muc_webchat_url: Fix default url
[prosody-modules.git] / mod_auto_answer_disco_info / mod_auto_answer_disco_info.lua
blob695e3bc88662319b8f328bca634a29da84a9dcee
1 module:depends("cache_c2s_caps");
3 local st = require "util.stanza";
5 local function disco_handler(event)
6 local stanza, origin = event.stanza, event.origin;
7 local query = stanza.tags[1];
8 local to = stanza.attr.to;
9 local node = query.attr.node;
11 local target_session = prosody.full_sessions[to];
12 if target_session == nil then
13 return;
14 end
16 local disco_info = target_session.caps_cache;
17 if disco_info ~= nil and (node == nil or node == disco_info.attr.node) then
18 local iq = st.reply(stanza);
19 iq:add_child(st.clone(disco_info));
20 local log = origin.log or module._log;
21 log("debug", "Answering disco#info on the behalf of %s", to);
22 module:send(iq);
23 return true;
24 end
25 end
27 module:hook("iq-get/full/http://jabber.org/protocol/disco#info:query", disco_handler, 1);