Mercurial > prosody-modules
changeset 3234:b1e25943a004
mod_bookmarks: Fire empty and updated events, for other modules to use.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 18 Aug 2018 16:55:52 +0100 |
parents | 176b537a658c |
children | bd8e94ff726b |
files | mod_bookmarks/mod_bookmarks.lua |
diffstat | 1 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_bookmarks/mod_bookmarks.lua Sat Aug 18 14:43:58 2018 +0100 +++ b/mod_bookmarks/mod_bookmarks.lua Sat Aug 18 16:55:52 2018 +0100 @@ -85,6 +85,12 @@ local data, err = private_storage:get(username, "storage:storage:bookmarks"); if not data then module:log("debug", "No existing Private XML bookmarks for %s, migration already done: %s", username, err); + local service = mod_pep.get_pep_service(username); + local ok, id = service:get_last_item("storage:bookmarks", session.full_jid); + if not ok or not id then + module:log("debug", "Additionally, no PEP bookmarks were existing for %s", username); + module:fire_event("bookmarks/empty", { session = session }); + end return; end local bookmarks = st.deserialize(data); @@ -106,6 +112,13 @@ module:log("debug", "Removed private bookmarks of %s, migration done!", username); end -module:hook("iq-get/bare/jabber:iq:private:query", on_retrieve_private_xml) -module:hook("iq-set/bare/jabber:iq:private:query", on_publish_private_xml) -module:hook("resource-bind", on_resource_bind) +local function on_item_published(event) + if event.node == "storage:bookmarks" then + module:fire_event("bookmarks/updated", event); + end +end + +module:hook("iq-get/bare/jabber:iq:private:query", on_retrieve_private_xml); +module:hook("iq-set/bare/jabber:iq:private:query", on_publish_private_xml); +module:hook("resource-bind", on_resource_bind); +module:hook("item-published", on_item_published);