diff options
author | Kim Alvefur <zash@zash.se> | 2019-01-10 15:39:02 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-01-10 15:39:02 +0100 |
commit | f7c48ad3bc1f4819ecb344729bf771887f6ab59b (patch) | |
tree | 33e30f7114e96a0356b5d3bf1d1c405a5801a5da | |
parent | cc4a160cdb7d02a3c08d7ccbb0ce3e04025137ad (diff) | |
download | prosody-f7c48ad3bc1f4819ecb344729bf771887f6ab59b.tar.gz prosody-f7c48ad3bc1f4819ecb344729bf771887f6ab59b.zip |
mod_vcard_legacy: Upgrade vcard-temp on login (fixes #1289)
-rw-r--r-- | plugins/mod_vcard_legacy.lua | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/plugins/mod_vcard_legacy.lua b/plugins/mod_vcard_legacy.lua index 80ce9e61..6a196b32 100644 --- a/plugins/mod_vcard_legacy.lua +++ b/plugins/mod_vcard_legacy.lua @@ -130,10 +130,6 @@ module:hook("iq-get/bare/vcard-temp:vCard", function (event) end end - if not vcard_temp.tags[1] then - vcard_temp = st.deserialize(vcards:get(jid_split(stanza.attr.to) or origin.username)) or vcard_temp; - end - origin.send(st.reply(stanza):add_child(vcard_temp)); return true; end); @@ -310,3 +306,21 @@ end module:hook("pre-presence/full", inject_xep153, 1); module:hook("pre-presence/bare", inject_xep153, 1); module:hook("pre-presence/host", inject_xep153, 1); + +module:hook("resource-bind", function (event) + local session = event.session; + local username = session.username; + local vcard_temp = vcards:get(username); + if not vcard_temp then + session.log("debug", "No legacy vCard to migrate or already migrated"); + 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"); + else + session.log("info", "Failed to migrate vCard-temp to PEP: %s", err or "problem emptying 'vcard' store"); + end +end); |