Mercurial > prosody-modules
changeset 1442:253e374824a8
mod_profile: Load profile into PEP on initial presence
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 21 Jun 2014 14:58:55 +0200 (2014-06-21) |
parents | 07c9306c2c1f |
children | faf1a5d89cd7 |
files | mod_profile/mod_profile.lua |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_profile/mod_profile.lua Fri Jun 20 18:14:26 2014 +0200 +++ b/mod_profile/mod_profile.lua Sat Jun 21 14:58:55 2014 +0200 @@ -12,6 +12,7 @@ pep_plus = module:depends"pep_plus"; end +local loaded_pep_for = module:shared"loaded-pep-for"; local storage = module:open_store(); local legacy_storage = module:open_store("vcard"); @@ -115,6 +116,7 @@ if pep_plus and username then update_pep(username, data); + loaded_pep_for[username] = true; end return origin.send(st.reply(stanza)); @@ -126,6 +128,17 @@ module:hook("iq-set/bare/vcard-temp:vCard", handle_set); module:hook("iq-set/host/vcard-temp:vCard", handle_set); +module:hook("presence/initial", function (event) + local username = event.origin.username + if not loaded_pep_for[username] then + data = storage:get(username); + if data then + update_pep(username, data); + end + loaded_pep_for[username] = true; + end +end); + -- The vCard4 part if vcard.to_vcard4 then module:add_feature("urn:ietf:params:xml:ns:vcard-4.0");