Changeset

9812:330a937e085e 0.11

mod_vcard_legacy: Don't overwrite existing PEP data
author Kim Alvefur <zash@zash.se>
date Fri, 25 Jan 2019 23:27:23 +0100
parents 9811:ce6eb482eb50
children 9813:071aaaa5cb34
files plugins/mod_vcard_legacy.lua
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_vcard_legacy.lua	Fri Jan 25 23:21:13 2019 +0100
+++ b/plugins/mod_vcard_legacy.lua	Fri Jan 25 23:27:23 2019 +0100
@@ -315,8 +315,15 @@
 		session.log("debug", "No legacy vCard to migrate or already migrated");
 		return;
 	end
+	local pep_service = mod_pep.get_pep_service(username);
+	if pep_service:get_last_item("urn:xmpp:vcard4", true)
+	or pep_service:get_last_item("urn:xmpp:avatar:metadata", true)
+	or pep_service:get_last_item("urn:xmpp:avatar:data", true) then
+		session.log("debug", "Already PEP data, not overwriting with migrated data");
+		vcards:set(username, nil);
+		return;
+	end
 	vcard_temp = st.deserialize(vcard_temp);
-	local pep_service = mod_pep.get_pep_service(username);
 	local ok, err = save_to_pep(pep_service, true, vcard_to_pep(vcard_temp));
 	if ok and vcards:set(username, nil) then
 		session.log("info", "Migrated vCard-temp to PEP");