# HG changeset patch # User Kim Alvefur # Date 1344537073 -7200 # Node ID 7e40d6680093f45d4c09f3aab6e94585b9760ad5 # Parent aeb0999f12fa02e06cdf2a6bce246176654c8e43 mod_vjud: Allow working as a component, in which case the parent domain is searched. diff -r aeb0999f12fa -r 7e40d6680093 mod_vjud/mod_vjud.lua --- a/mod_vjud/mod_vjud.lua Thu Aug 09 20:16:09 2012 +0200 +++ b/mod_vjud/mod_vjud.lua Thu Aug 09 20:31:13 2012 +0200 @@ -28,6 +28,12 @@ ]]; +local base_host = module:get_option_string("vjud_search_domain", + module:get_host_type() == "component" + and module.host:gsub("^[^.]+%.","") + or module.host); + +module:depends"disco"; module:add_feature("jabber:iq:search"); local opted_in; @@ -60,8 +66,8 @@ end }; -local function get_user_vcard(user) - local vCard = dm_load(user, module.host, "vcard"); +local function get_user_vcard(user, host) + local vCard = dm_load(user, host or base_host, "vcard"); if vCard then vCard = st.deserialize(vCard); vCard = vcard.from_xep54(vCard); @@ -69,7 +75,7 @@ end end -local at_host = "@"..module.host; +local at_host = "@"..base_host; module:hook("iq/host/jabber:iq:search:query", function(event) local origin, stanza = event.origin, event.stanza; @@ -92,7 +98,7 @@ local reply = st.reply(stanza):query("jabber:iq:search"); local username, hostname = jid_split(email); - if hostname == module.host and username and usermanager.user_exists(username, hostname) then + if hostname == base_host and username and usermanager.user_exists(username, hostname) then local vCard = get_user_vcard(username); if vCard then reply:add_child(item_template.apply{ @@ -133,7 +139,7 @@ return { status = "canceled" }; end - if not username or not hostname or hostname ~= module.host then + if not username or not hostname or hostname ~= base_host then return { status = "error", error = { type = "cancel", condition = "forbidden", message = "Invalid user or hostname." } }; end