diff options
author | Matthew Wild <mwild1@gmail.com> | 2025-02-06 17:03:03 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2025-02-06 17:03:03 +0000 |
commit | 839498eb5d7f275c21e0f63939b79bf0ff1f5fc1 (patch) | |
tree | 679239746619d6348af7a68005f4c5c9d663a9f1 | |
parent | eac45d938aac894a9599f1f9351a364862b5c23d (diff) | |
download | prosody-839498eb5d7f275c21e0f63939b79bf0ff1f5fc1.tar.gz prosody-839498eb5d7f275c21e0f63939b79bf0ff1f5fc1.zip |
mod_vcard: Some support for handling vcards on components
-rw-r--r-- | plugins/mod_vcard.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/mod_vcard.lua b/plugins/mod_vcard.lua index cb3bfdeb..4cb14f81 100644 --- a/plugins/mod_vcard.lua +++ b/plugins/mod_vcard.lua @@ -7,6 +7,7 @@ -- local base64 = require "prosody.util.encodings".base64; +local jid = require "prosody.util.jid"; local sha1 = require "prosody.util.hashes".sha1; local st = require "prosody.util.stanza" local jid_split = require "prosody.util.jid".split; @@ -15,6 +16,8 @@ local vcards = module:open_store(); module:add_feature("vcard-temp"); +local is_component = module:get_host_type() == "component"; + local function handle_vcard(event) local session, stanza = event.origin, event.stanza; local to = stanza.attr.to; @@ -23,7 +26,7 @@ local function handle_vcard(event) if to then local node = jid_split(to); vCard = st.deserialize(vcards:get(node)); -- load vCard for user or server - else + elseif not is_component then vCard = st.deserialize(vcards:get(session.username));-- load user's own vCard end if vCard then @@ -32,8 +35,9 @@ local function handle_vcard(event) session.send(st.error_reply(stanza, "cancel", "item-not-found")); end else -- stanza.attr.type == "set" - if not to then - if vcards:set(session.username, st.preserialize(stanza.tags[1])) then + if not to or (is_component and event.allow_vcard_modification) then + local node = is_component and jid.node(stanza.attr.to) or session.username; + if vcards:set(node, st.preserialize(stanza.tags[1])) then session.send(st.reply(stanza)); module:fire_event("vcard-updated", event); else |