diff options
author | Kim Alvefur <zash@zash.se> | 2018-08-20 07:36:03 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-08-20 07:36:03 +0200 |
commit | 4b787a63a5e801e53542f7f4eb9391afb3b05121 (patch) | |
tree | 8da1ca5d2967773da3e455107c3a0fcfcd1be572 /plugins | |
parent | 512f69098bf90332b5abaa735e056c3149dab405 (diff) | |
download | prosody-4b787a63a5e801e53542f7f4eb9391afb3b05121.tar.gz prosody-4b787a63a5e801e53542f7f4eb9391afb3b05121.zip |
mod_vcard_legacy: Attach vcard-temp avatar hash to outgoing presence
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_vcard_legacy.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/mod_vcard_legacy.lua b/plugins/mod_vcard_legacy.lua index 08f18b5b..7bc09638 100644 --- a/plugins/mod_vcard_legacy.lua +++ b/plugins/mod_vcard_legacy.lua @@ -53,3 +53,22 @@ module:hook("iq-get/bare/vcard-temp:vCard", function (event) origin.send(st.reply(stanza):add_child(vcard_temp)); return true; end); + +local function inject_xep153(event) + local origin, stanza = event.origin, event.stanza; + local username = origin.username; + if not username then return end + local pep = mod_pep.get_pep_service(username); + + stanza:remove_children("x", "vcard-temp:x:update"); + local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" }); + local ok, avatar_hash = pep:get_last_item("urn:xmpp:avatar:metadata", true); + if ok and avatar_hash then + x_update:text_tag("photo", avatar_hash); + end + stanza:add_direct_child(x_update); +end + +module:hook("pre-presence/full", inject_xep153, 1); +module:hook("pre-presence/bare", inject_xep153, 1); +module:hook("pre-presence/host", inject_xep153, 1); |