Comparison

mod_bookmarks/mod_bookmarks.lua @ 3230:ba0d444b64aa

mod_bookmarks: Simplify last item retrieval thanks to Prosody b6ffd4f951b9.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 18 Aug 2018 14:04:40 +0100
parent 3229:e8963e328b26
child 3231:f7777bc6e677
comparison
equal deleted inserted replaced
3229:e8963e328b26 3230:ba0d444b64aa
17 local bookmarks = query:get_child("storage", "storage:bookmarks"); 17 local bookmarks = query:get_child("storage", "storage:bookmarks");
18 if bookmarks == nil then 18 if bookmarks == nil then
19 return; 19 return;
20 end 20 end
21 21
22 module:log("debug", "Getting private %s", bookmarks); 22 module:log("debug", "Getting private bookmarks: %s", bookmarks);
23 23
24 local username = session.username; 24 local username = session.username;
25 local service = mod_pep.get_pep_service(username); 25 local service = mod_pep.get_pep_service(username);
26 module:log("debug", "%s", session.full_jid); 26 module:log("debug", "%s", session.full_jid);
27 local ok, id = service:get_last_item("storage:bookmarks", session.full_jid); 27 local ok, id, item = service:get_last_item("storage:bookmarks", session.full_jid);
28 if not ok then 28 if not ok then
29 module:log("error", "Failed to PEP bookmarks’ last id of %s: %s", username, id); 29 module:log("error", "Failed to retrieve PEP bookmarks of %s: %s", username, id);
30 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to retrive bookmarks from PEP"));
31 return;
32 end
33
34 local ok, data = service:get_items("storage:bookmarks", session.full_jid, id);
35 if not ok then
36 module:log("error", "Failed to retrieve PEP bookmarks of %s: %s", username, data);
37 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to retrive bookmarks from PEP")); 30 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to retrive bookmarks from PEP"));
38 return; 31 return;
39 end 32 end
40 33
41 local item = data[id]; 34 local item = data[id];