MT#18041 mod_sipwise_vjud: fix discovery, clean code

Change-Id: Idd76d16f9a27fd9b10641085c8182654e63e9be3
changes/12/4712/1
Victor Seva 9 years ago
parent c122e4e1ed
commit f6031ab582

@ -66,26 +66,6 @@ local params = module:get_option("auth_sql", {
local engine = mod_sql:create_engine(params);
engine:execute("SET NAMES 'utf8' COLLATE 'utf8_bin';");
local function get_disco_info(stanza)
return st.iq({type='result', id=stanza.attr.id, from=module:get_host(), to=stanza.attr.from}):query("http://jabber.org/protocol/disco#info"):tag("feature", {var="jabber:iq:search"}); -- TODO cache disco reply
end
local function handle_to_domain(event)
local origin, stanza = event.origin, event.stanza;
local type = stanza.attr.type;
if type == "error" or type == "result" then return; end
if stanza.name == "iq" and type == "get" then
local xmlns = stanza.tags[1].attr.xmlns;
local node = stanza.tags[1].attr.node;
if xmlns == "http://jabber.org/protocol/disco#info" and not node then
origin.send(get_disco_info(stanza));
else
origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- TODO disco/etc
end
end
return true;
end
local function normalize_number(user, host, number)
local locale_info = {};
for row in engine:select(locale_query, user, host) do
@ -195,4 +175,3 @@ module:hook("iq/host/jabber:iq:search:query", function(event)
return origin.send(reply);
end
end);
module:hook("iq/host", handle_to_domain, -1);

Loading…
Cancel
Save