Software /
code /
prosody-modules
Changeset
789:7e40d6680093
mod_vjud: Allow working as a component, in which case the parent domain is searched.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 09 Aug 2012 20:31:13 +0200 |
parents | 788:aeb0999f12fa |
children | 790:4f9cd19c4658 |
files | mod_vjud/mod_vjud.lua |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ </item> ]]; +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