Software / code / prosody
Comparison
plugins/mod_vcard_legacy.lua @ 10270:c2b9ff42db03
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 21 Sep 2019 16:50:29 +0200 |
| parent | 10215:82abf88db13f |
| parent | 10269:4701415f5b0e |
| child | 10549:3e50f86e5a2e |
comparison
equal
deleted
inserted
replaced
| 10267:9ef1e26594cb | 10270:c2b9ff42db03 |
|---|---|
| 319 local username = origin.username; | 319 local username = origin.username; |
| 320 if not username then return end | 320 if not username then return end |
| 321 if stanza.attr.type then return end | 321 if stanza.attr.type then return end |
| 322 local pep_service = mod_pep.get_pep_service(username); | 322 local pep_service = mod_pep.get_pep_service(username); |
| 323 | 323 |
| 324 stanza:remove_children("x", "vcard-temp:x:update"); | 324 local x_update = stanza:get_child("x", "vcard-temp:x:update"); |
| 325 local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" }); | 325 if not x_update then |
| 326 x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" }):tag("photo"); | |
| 327 stanza:add_direct_child(x_update); | |
| 328 elseif x_update:get_child("photo") then | |
| 329 return; -- XEP implies that these should be left alone | |
| 330 else | |
| 331 x_update:tag("photo"); | |
| 332 end | |
| 326 local ok, avatar_hash = pep_service:get_last_item("urn:xmpp:avatar:metadata", true); | 333 local ok, avatar_hash = pep_service:get_last_item("urn:xmpp:avatar:metadata", true); |
| 327 if ok and avatar_hash then | 334 if ok and avatar_hash then |
| 328 x_update:text_tag("photo", avatar_hash); | 335 x_update:text(avatar_hash); |
| 329 end | 336 end |
| 330 stanza:add_direct_child(x_update); | |
| 331 end | 337 end |
| 332 | 338 |
| 333 module:hook("pre-presence/full", inject_xep153, 1); | 339 module:hook("pre-presence/full", inject_xep153, 1); |
| 334 module:hook("pre-presence/bare", inject_xep153, 1); | 340 module:hook("pre-presence/bare", inject_xep153, 1); |
| 335 module:hook("pre-presence/host", inject_xep153, 1); | 341 module:hook("pre-presence/host", inject_xep153, 1); |