Changeset

10865:9c27b2385fad

mod_vcard_legacy: Fix publishing vcard without avatar
author Kim Alvefur <zash@zash.se>
date Mon, 01 Jun 2020 17:55:01 +0200
parents 10864:1b657605ea29
children 10866:5265f7fe11dd
files plugins/mod_vcard_legacy.lua
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_vcard_legacy.lua	Mon Jun 01 17:37:54 2020 +0200
+++ b/plugins/mod_vcard_legacy.lua	Mon Jun 01 17:55:01 2020 +0200
@@ -276,12 +276,14 @@
 			pep_service:purge("urn:xmpp:avatar:data", actor);
 		end
 
-		local ok, err = pep_service:publish("urn:xmpp:avatar:data", actor, avatar.hash, avatar.data, node_defaults);
-		if ok then
-			ok, err = pep_service:publish("urn:xmpp:avatar:metadata", actor, avatar.hash, avatar.meta, node_defaults);
-		end
-		if not ok then
-			return ok, err;
+		if avatar.data and avatar.meta then
+			local ok, err = assert(pep_service:publish("urn:xmpp:avatar:data", actor, avatar.hash, avatar.data, node_defaults));
+			if ok then
+				ok, err = assert(pep_service:publish("urn:xmpp:avatar:metadata", actor, avatar.hash, avatar.meta, node_defaults));
+			end
+			if not ok then
+				return ok, err;
+			end
 		end
 	end