388
|
1
|
|
2 local helper = require "util.discohelper".new();
|
|
3 local hosts = hosts;
|
|
4 local jid_split = require "util.jid".split;
|
|
5 local jid_bare = require "util.jid".bare;
|
|
6 local usermanager_user_exists = require "core.usermanager".user_exists;
|
|
7 local rostermanager_is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
|
|
8
|
|
9 do
|
|
10 helper:addDiscoInfoHandler("*host", function(reply, to, from, node)
|
|
11 if hosts[to] then
|
|
12 reply:tag("identity", {category="server", type="im", name="ejabberd"}):up();
|
|
13 return true;
|
|
14 end
|
|
15 end);
|
|
16 helper:addDiscoInfoHandler("*node", function(reply, to, from, node)
|
|
17 local node, host = jid_split(to);
|
|
18 if hosts[host] and rostermanager_is_contact_subscribed(node, host, jid_bare(from)) then
|
|
19 reply:tag("identity", {category="account", type="registered"}):up();
|
|
20 return true;
|
|
21 end
|
|
22 end);
|
|
23 end
|
|
24
|
|
25 module "discomanager"
|
|
26
|
|
27 function handle(stanza)
|
|
28 return helper:handle(stanza);
|
|
29 end
|
|
30
|
|
31 function addDiscoItemsHandler(jid, func)
|
|
32 return helper:addDiscoItemsHandler(jid, func);
|
|
33 end
|
|
34
|
|
35 function addDiscoInfoHandler(jid, func)
|
|
36 return helper:addDiscoInfoHandler(jid, func);
|
|
37 end
|
|
38
|
|
39 return _M;
|