Software /
code /
prosody
Comparison
plugins/mod_vcard_legacy.lua @ 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 |
parent | 9811:ce6eb482eb50 |
child | 9813:071aaaa5cb34 |
comparison
equal
deleted
inserted
replaced
9811:ce6eb482eb50 | 9812:330a937e085e |
---|---|
313 local vcard_temp = vcards:get(username); | 313 local vcard_temp = vcards:get(username); |
314 if not vcard_temp then | 314 if not vcard_temp then |
315 session.log("debug", "No legacy vCard to migrate or already migrated"); | 315 session.log("debug", "No legacy vCard to migrate or already migrated"); |
316 return; | 316 return; |
317 end | 317 end |
318 local pep_service = mod_pep.get_pep_service(username); | |
319 if pep_service:get_last_item("urn:xmpp:vcard4", true) | |
320 or pep_service:get_last_item("urn:xmpp:avatar:metadata", true) | |
321 or pep_service:get_last_item("urn:xmpp:avatar:data", true) then | |
322 session.log("debug", "Already PEP data, not overwriting with migrated data"); | |
323 vcards:set(username, nil); | |
324 return; | |
325 end | |
318 vcard_temp = st.deserialize(vcard_temp); | 326 vcard_temp = st.deserialize(vcard_temp); |
319 local pep_service = mod_pep.get_pep_service(username); | |
320 local ok, err = save_to_pep(pep_service, true, vcard_to_pep(vcard_temp)); | 327 local ok, err = save_to_pep(pep_service, true, vcard_to_pep(vcard_temp)); |
321 if ok and vcards:set(username, nil) then | 328 if ok and vcards:set(username, nil) then |
322 session.log("info", "Migrated vCard-temp to PEP"); | 329 session.log("info", "Migrated vCard-temp to PEP"); |
323 else | 330 else |
324 session.log("info", "Failed to migrate vCard-temp to PEP: %s", err or "problem emptying 'vcard' store"); | 331 session.log("info", "Failed to migrate vCard-temp to PEP: %s", err or "problem emptying 'vcard' store"); |