mod_pep_vcard_avatar: Return early if no vcard is given

Sun, 03 Apr 2016 00:19:11 +0200

author
Kim Alvefur <zash@zash.se>
date
Sun, 03 Apr 2016 00:19:11 +0200
changeset 2149
d9e91240a2dd
parent 2148
c472a454be61
child 2150
c1ecc3bc88fa

mod_pep_vcard_avatar: Return early if no vcard is given

mod_pep_vcard_avatar/mod_pep_vcard_avatar.lua file | annotate | diff | comparison | revisions
--- 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");

mercurial