comparison mod_profile/mod_profile.lua @ 3252:eec70a863d16

mod_profile: Only replace avatar update hash if one is found
author Kim Alvefur <zash@zash.se>
date Tue, 21 Aug 2018 11:01:46 +0200
parents 60821653c5a9
children 628659e2e6b0
comparison
equal deleted inserted replaced
3251:60821653c5a9 3252:eec70a863d16
243 local origin, stanza = event.origin, event.stanza; 243 local origin, stanza = event.origin, event.stanza;
244 local username = origin.username; 244 local username = origin.username;
245 if not username then return end 245 if not username then return end
246 local pep = pep_plus.get_pep_service(username); 246 local pep = pep_plus.get_pep_service(username);
247 247
248 stanza:remove_children("x", "vcard-temp:x:update");
249 local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" });
250 local ok, avatar_hash = pep:get_last_item("urn:xmpp:avatar:metadata", true); 248 local ok, avatar_hash = pep:get_last_item("urn:xmpp:avatar:metadata", true);
251 if ok and avatar_hash then 249 if ok and avatar_hash then
250 stanza:remove_children("x", "vcard-temp:x:update");
251 local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" });
252 x_update:text_tag("photo", avatar_hash); 252 x_update:text_tag("photo", avatar_hash);
253 end 253 stanza:add_direct_child(x_update);
254 stanza:add_direct_child(x_update); 254 end
255 end 255 end
256 256
257 if pep_plus then 257 if pep_plus then
258 module:hook("pre-presence/full", inject_xep153, 1) 258 module:hook("pre-presence/full", inject_xep153, 1)
259 module:hook("pre-presence/bare", inject_xep153, 1) 259 module:hook("pre-presence/bare", inject_xep153, 1)