Software /
code /
prosody-modules
Comparison
mod_bookmarks/mod_bookmarks.lua @ 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 |
parent | 3233:176b537a658c |
child | 3235:bd8e94ff726b |
comparison
equal
deleted
inserted
replaced
3233:176b537a658c | 3234:b1e25943a004 |
---|---|
83 local username = session.username; | 83 local username = session.username; |
84 | 84 |
85 local data, err = private_storage:get(username, "storage:storage:bookmarks"); | 85 local data, err = private_storage:get(username, "storage:storage:bookmarks"); |
86 if not data then | 86 if not data then |
87 module:log("debug", "No existing Private XML bookmarks for %s, migration already done: %s", username, err); | 87 module:log("debug", "No existing Private XML bookmarks for %s, migration already done: %s", username, err); |
88 local service = mod_pep.get_pep_service(username); | |
89 local ok, id = service:get_last_item("storage:bookmarks", session.full_jid); | |
90 if not ok or not id then | |
91 module:log("debug", "Additionally, no PEP bookmarks were existing for %s", username); | |
92 module:fire_event("bookmarks/empty", { session = session }); | |
93 end | |
88 return; | 94 return; |
89 end | 95 end |
90 local bookmarks = st.deserialize(data); | 96 local bookmarks = st.deserialize(data); |
91 module:log("debug", "Got private bookmarks of %s: %s", username, bookmarks); | 97 module:log("debug", "Got private bookmarks of %s: %s", username, bookmarks); |
92 | 98 |
104 return; | 110 return; |
105 end | 111 end |
106 module:log("debug", "Removed private bookmarks of %s, migration done!", username); | 112 module:log("debug", "Removed private bookmarks of %s, migration done!", username); |
107 end | 113 end |
108 | 114 |
109 module:hook("iq-get/bare/jabber:iq:private:query", on_retrieve_private_xml) | 115 local function on_item_published(event) |
110 module:hook("iq-set/bare/jabber:iq:private:query", on_publish_private_xml) | 116 if event.node == "storage:bookmarks" then |
111 module:hook("resource-bind", on_resource_bind) | 117 module:fire_event("bookmarks/updated", event); |
118 end | |
119 end | |
120 | |
121 module:hook("iq-get/bare/jabber:iq:private:query", on_retrieve_private_xml); | |
122 module:hook("iq-set/bare/jabber:iq:private:query", on_publish_private_xml); | |
123 module:hook("resource-bind", on_resource_bind); | |
124 module:hook("item-published", on_item_published); |