Changeset

2217:7be1ca7a51a4

mod_pep_vcard_png_avatar: Fix Lua warnings
author Michel Le Bihan <michel@lebihan.pl>
date Fri, 24 Jun 2016 22:06:56 +0200
parents 2216:7f36ec9c836e
children 2218:0ca0fdad3b2c
files mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua	Fri Jun 24 19:16:01 2016 +0200
+++ b/mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua	Fri Jun 24 22:06:56 2016 +0200
@@ -113,18 +113,17 @@
 		module:log("error", "No photo found");
 		return;
 	end -- Publishing in the wrong order?
+	local image=pep_photo:get_child_text("data", "urn:xmpp:avatar:data");
 	if pep_photo and metadata.attr.type == "image/webp" then
-		file_webp = io.open("/tmp/Prosody_temp_avatar.webp", "w");
+		local file_webp = io.open("/tmp/Prosody_temp_avatar.webp", "w");
 		file_webp:write(base64.decode(pep_photo:get_child_text("data", "urn:xmpp:avatar:data")));
 		file_webp:close();
 		os.execute("convert /tmp/Prosody_temp_avatar.webp /tmp/Prosody_temp_avatar.png");
-		file_png = io.open("/tmp/Prosody_temp_avatar.png", "r");
+		local file_png = io.open("/tmp/Prosody_temp_avatar.png", "r");
 		image=base64.encode(file_png:read("*a"));
 		file_png:close();
 		os.remove("/tmp/Prosody_temp_avatar.webp");
 		os.remove("/tmp/Prosody_temp_avatar.png");
-	else
-		image=pep_photo:get_child_text("data", "urn:xmpp:avatar:data");
 	end
 	local vcard = get_vcard(username);
 	local new_photo = st.stanza("PHOTO", { xmlns = "vcard-temp" })