Diff

mod_pep_vcard_avatar/mod_pep_vcard_avatar.lua @ 2149:d9e91240a2dd

mod_pep_vcard_avatar: Return early if no vcard is given
author Kim Alvefur <zash@zash.se>
date Sun, 03 Apr 2016 00:19:11 +0200
parent 1591:21e439ca7208
child 2150:c1ecc3bc88fa
line wrap: on
line diff
--- a/mod_pep_vcard_avatar/mod_pep_vcard_avatar.lua	Sat Apr 02 20:03:30 2016 +0200
+++ b/mod_pep_vcard_avatar/mod_pep_vcard_avatar.lua	Sun Apr 03 00:19:11 2016 +0200
@@ -44,13 +44,14 @@
 
 -- vCard -> PEP
 local function update_pep(session, vcard)
-	local nickname = vcard and vcard:get_child_text("NICKNAME");
+	if not vcard then return end
+	local nickname = vcard:get_child_text("NICKNAME");
 	if nickname then
 		publish(session, "http://jabber.org/protocol/nick", "current", st.stanza("item", {id="current"})
 			:tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname));
 	end
 
-	local photo = vcard and vcard:get_child("PHOTO");
+	local photo = vcard:get_child("PHOTO");
 	if photo then
 		local photo_type = photo:get_child_text("TYPE");
 		local photo_b64 = photo:get_child_text("BINVAL");