# HG changeset patch # User Emmanuel Gil Peyrot # Date 1534607752 -3600 # Node ID b1e25943a0045aa016227e052d58da743aa03eaa # Parent 176b537a658c918d3d43b3167bea1d5b6d219476 mod_bookmarks: Fire empty and updated events, for other modules to use. diff -r 176b537a658c -r b1e25943a004 mod_bookmarks/mod_bookmarks.lua --- 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);