Software /
code /
prosody
Comparison
plugins/mod_vcard_legacy.lua @ 10269:4701415f5b0e 0.11
mod_vcard_legacy: Don't owerwrite empty photo elements (fixes #1432)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 21 Sep 2019 16:29:16 +0200 |
parent | 10268:210278d5f995 |
child | 10270:c2b9ff42db03 |
comparison
equal
deleted
inserted
replaced
10268:210278d5f995 | 10269:4701415f5b0e |
---|---|
298 local username = origin.username; | 298 local username = origin.username; |
299 if not username then return end | 299 if not username then return end |
300 if stanza.attr.type then return end | 300 if stanza.attr.type then return end |
301 local pep_service = mod_pep.get_pep_service(username); | 301 local pep_service = mod_pep.get_pep_service(username); |
302 | 302 |
303 stanza:remove_children("x", "vcard-temp:x:update"); | 303 local x_update = stanza:get_child("x", "vcard-temp:x:update"); |
304 local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" }):tag("photo"); | 304 if not x_update then |
305 x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" }):tag("photo"); | |
306 stanza:add_direct_child(x_update); | |
307 elseif x_update:get_child("photo") then | |
308 return; -- XEP implies that these should be left alone | |
309 else | |
310 x_update:tag("photo"); | |
311 end | |
305 local ok, avatar_hash = pep_service:get_last_item("urn:xmpp:avatar:metadata", true); | 312 local ok, avatar_hash = pep_service:get_last_item("urn:xmpp:avatar:metadata", true); |
306 if ok and avatar_hash then | 313 if ok and avatar_hash then |
307 x_update:text(avatar_hash); | 314 x_update:text(avatar_hash); |
308 end | 315 end |
309 stanza:add_direct_child(x_update); | |
310 end | 316 end |
311 | 317 |
312 module:hook("pre-presence/full", inject_xep153, 1); | 318 module:hook("pre-presence/full", inject_xep153, 1); |
313 module:hook("pre-presence/bare", inject_xep153, 1); | 319 module:hook("pre-presence/bare", inject_xep153, 1); |
314 module:hook("pre-presence/host", inject_xep153, 1); | 320 module:hook("pre-presence/host", inject_xep153, 1); |