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
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
);
27 module
:hook("iq-get/full/http://jabber.org/protocol/disco#info:query", disco_handler
, 1);