Mercurial > prosody-modules
comparison mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua @ 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 | 7f36ec9c836e |
children | e6a3bdbce7b9 |
comparison
equal
deleted
inserted
replaced
2216:7f36ec9c836e | 2217:7be1ca7a51a4 |
---|---|
111 pep_photo = pep_photo and pep_photo[1] == metadata.attr.id and pep_photo[2]; | 111 pep_photo = pep_photo and pep_photo[1] == metadata.attr.id and pep_photo[2]; |
112 if not pep_photo then | 112 if not pep_photo then |
113 module:log("error", "No photo found"); | 113 module:log("error", "No photo found"); |
114 return; | 114 return; |
115 end -- Publishing in the wrong order? | 115 end -- Publishing in the wrong order? |
116 local image=pep_photo:get_child_text("data", "urn:xmpp:avatar:data"); | |
116 if pep_photo and metadata.attr.type == "image/webp" then | 117 if pep_photo and metadata.attr.type == "image/webp" then |
117 file_webp = io.open("/tmp/Prosody_temp_avatar.webp", "w"); | 118 local file_webp = io.open("/tmp/Prosody_temp_avatar.webp", "w"); |
118 file_webp:write(base64.decode(pep_photo:get_child_text("data", "urn:xmpp:avatar:data"))); | 119 file_webp:write(base64.decode(pep_photo:get_child_text("data", "urn:xmpp:avatar:data"))); |
119 file_webp:close(); | 120 file_webp:close(); |
120 os.execute("convert /tmp/Prosody_temp_avatar.webp /tmp/Prosody_temp_avatar.png"); | 121 os.execute("convert /tmp/Prosody_temp_avatar.webp /tmp/Prosody_temp_avatar.png"); |
121 file_png = io.open("/tmp/Prosody_temp_avatar.png", "r"); | 122 local file_png = io.open("/tmp/Prosody_temp_avatar.png", "r"); |
122 image=base64.encode(file_png:read("*a")); | 123 image=base64.encode(file_png:read("*a")); |
123 file_png:close(); | 124 file_png:close(); |
124 os.remove("/tmp/Prosody_temp_avatar.webp"); | 125 os.remove("/tmp/Prosody_temp_avatar.webp"); |
125 os.remove("/tmp/Prosody_temp_avatar.png"); | 126 os.remove("/tmp/Prosody_temp_avatar.png"); |
126 else | |
127 image=pep_photo:get_child_text("data", "urn:xmpp:avatar:data"); | |
128 end | 127 end |
129 local vcard = get_vcard(username); | 128 local vcard = get_vcard(username); |
130 local new_photo = st.stanza("PHOTO", { xmlns = "vcard-temp" }) | 129 local new_photo = st.stanza("PHOTO", { xmlns = "vcard-temp" }) |
131 :tag("TYPE"):text(metadata.attr.type):up() | 130 :tag("TYPE"):text(metadata.attr.type):up() |
132 :tag("BINVAL"):text(image); | 131 :tag("BINVAL"):text(image); |