changeset 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 cf8ad9fd7f15
files mod_profile/mod_profile.lua
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_profile/mod_profile.lua	Tue Aug 21 11:00:30 2018 +0200
+++ b/mod_profile/mod_profile.lua	Tue Aug 21 11:01:46 2018 +0200
@@ -245,13 +245,13 @@
 	if not username then return end
 	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 ok, avatar_hash = pep:get_last_item("urn:xmpp:avatar:metadata", true);
 	if ok and avatar_hash then
+		stanza:remove_children("x", "vcard-temp:x:update");
+		local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" });
 		x_update:text_tag("photo", avatar_hash);
+		stanza:add_direct_child(x_update);
 	end
-	stanza:add_direct_child(x_update);
 end
 
 if pep_plus then