--- /dev/null
+\r
+local helper = require "util.discohelper".new();\r
+local hosts = hosts;\r
+local jid_split = require "util.jid".split;\r
+local jid_bare = require "util.jid".bare;\r
+local usermanager_user_exists = require "core.usermanager".user_exists;\r
+local rostermanager_is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;\r
+\r
+do\r
+ helper:addDiscoInfoHandler("*host", function(reply, to, from, node)\r
+ if hosts[to] then\r
+ reply:tag("identity", {category="server", type="im", name="ejabberd"}):up();\r
+ return true;\r
+ end\r
+ end);\r
+ helper:addDiscoInfoHandler("*node", function(reply, to, from, node)\r
+ local node, host = jid_split(to);\r
+ if hosts[host] and rostermanager_is_contact_subscribed(node, host, jid_bare(from)) then\r
+ reply:tag("identity", {category="account", type="registered"}):up();\r
+ return true;\r
+ end\r
+ end);\r
+end\r
+\r
+module "discomanager"\r
+\r
+function handle(stanza)\r
+ return helper:handle(stanza);\r
+end\r
+\r
+function addDiscoItemsHandler(jid, func)\r
+ return helper:addDiscoItemsHandler(jid, func);\r
+end\r
+\r
+function addDiscoInfoHandler(jid, func)\r
+ return helper:addDiscoInfoHandler(jid, func);\r
+end\r
+\r
+return _M;\r