mod_vcard_legacy: Handle incomplete avatar info
authorKim Alvefur <zash@zash.se>
Sat, 01 Sep 2018 23:42:33 +0200
changeset 9260 05bd21c122ae
parent 9259 12d3d96e3918
child 9261 0cc535668fce
mod_vcard_legacy: Handle incomplete avatar info
plugins/mod_vcard_legacy.lua
--- a/plugins/mod_vcard_legacy.lua	Tue Aug 21 17:16:30 2018 +0200
+++ b/plugins/mod_vcard_legacy.lua	Sat Sep 01 23:42:33 2018 +0200
@@ -107,11 +107,15 @@
 		for _, hash in ipairs(avatar_meta) do
 			local meta = avatar_meta[hash];
 			local data = avatar_data[hash];
-			local info = meta.tags[1]:get_child("info");
-			vcard_temp:tag("PHOTO")
-				:text_tag("TYPE", info and info.attr.type)
-				:text_tag("BINVAL", data.tags[1]:get_text())
-				:up();
+			local info = meta and meta.tags[1]:get_child("info");
+			vcard_temp:tag("PHOTO");
+			if info and info.attr.type then
+				vcard_temp:text_tag("TYPE", info.attr.type);
+			end
+			if data then
+				vcard_temp:text_tag("BINVAL", data.tags[1]:get_text());
+			end
+			vcard_temp:up();
 		end
 	end