aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-01-10 15:39:02 +0100
committerKim Alvefur <zash@zash.se>2019-01-10 15:39:02 +0100
commit5fa2fa50591149accd8af637d8d3a4e932dfab8a (patch)
tree33e30f7114e96a0356b5d3bf1d1c405a5801a5da /plugins
parent2db6a382cddf53ea0ef4a85beb6458eab4b4001e (diff)
downloadprosody-5fa2fa50591149accd8af637d8d3a4e932dfab8a.tar.gz
prosody-5fa2fa50591149accd8af637d8d3a4e932dfab8a.zip
mod_vcard_legacy: Upgrade vcard-temp on login (fixes #1289)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_vcard_legacy.lua22
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);