aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-09-21 16:29:16 +0200
committerKim Alvefur <zash@zash.se>2019-09-21 16:29:16 +0200
commit54f1f9f4fc6a8e7a3d9ade646f4913717fbeb734 (patch)
treec886bb82e5f5ca969a7e54ff4c22b61458fbf737
parent9d55062487cc7af2f1921f9f2e75a6d7f04146e4 (diff)
downloadprosody-54f1f9f4fc6a8e7a3d9ade646f4913717fbeb734.tar.gz
prosody-54f1f9f4fc6a8e7a3d9ade646f4913717fbeb734.zip
mod_vcard_legacy: Don't owerwrite empty photo elements (fixes #1432)
-rw-r--r--plugins/mod_vcard_legacy.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/mod_vcard_legacy.lua b/plugins/mod_vcard_legacy.lua
index 6229b931..5e75947a 100644
--- a/plugins/mod_vcard_legacy.lua
+++ b/plugins/mod_vcard_legacy.lua
@@ -300,13 +300,19 @@ local function inject_xep153(event)
if stanza.attr.type then return end
local pep_service = 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" }):tag("photo");
+ local x_update = stanza:get_child("x", "vcard-temp:x:update");
+ if not x_update then
+ x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" }):tag("photo");
+ stanza:add_direct_child(x_update);
+ elseif x_update:get_child("photo") then
+ return; -- XEP implies that these should be left alone
+ else
+ x_update:tag("photo");
+ end
local ok, avatar_hash = pep_service:get_last_item("urn:xmpp:avatar:metadata", true);
if ok and avatar_hash then
x_update:text(avatar_hash);
end
- stanza:add_direct_child(x_update);
end
module:hook("pre-presence/full", inject_xep153, 1);