Software /
code /
prosody-modules
Diff
mod_profile/mod_profile.lua @ 3186:1fe5b156d220
mod_profile: Add support for XEP-0398
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 13 Jul 2018 01:13:37 +0200 |
parent | 3185:973caebcb40b |
child | 3187:7c450c27d4ba |
line wrap: on
line diff
--- a/mod_profile/mod_profile.lua Fri Jul 13 01:13:06 2018 +0200 +++ b/mod_profile/mod_profile.lua Fri Jul 13 01:13:37 2018 +0200 @@ -20,6 +20,10 @@ local storage = module:open_store(); local legacy_storage = module:open_store("vcard"); +module:hook("account-disco-info", function (event) + event.reply:tag("feature", { var = "urn:xmpp:pep-vcard-conversion:0" }):up(); +end); + local function get_item(vcard, name) -- luacheck: ignore 431 local item; for i=1, #vcard do @@ -233,3 +237,22 @@ end end +local function inject_xep153(event) + local origin, stanza = event.origin, event.stanza; + local username = origin.username; + local pep = pep_plus.get_pep_service(username); + + stanza:remove_children("x", "vcard-temp:x:update"); + local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" }); + local avatar_hash = pep:get_items("urn:xmpp:avatar:metadata"); + if avatar_hash then + x_update:text_tag("photo", avatar_hash); + end + stanza:add_direct_child(x_update); +end + +if pep_plus then + module:hook("pre-presence/full", inject_xep153) + module:hook("pre-presence/bare", inject_xep153) + module:hook("pre-presence/host", inject_xep153) +end