# HG changeset patch # User Kim Alvefur # Date 1403355535 -7200 # Node ID 253e374824a847a03a39a192f8b94def78eddf37 # Parent 07c9306c2c1f49790ca34e822a260ec54017a0a5 mod_profile: Load profile into PEP on initial presence diff -r 07c9306c2c1f -r 253e374824a8 mod_profile/mod_profile.lua --- 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");