comparison mod_bookmarks/mod_bookmarks.lua @ 3233:176b537a658c

mod_bookmarks: Send back empty Private XML bookmarks on empty PEP bookmarks.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 18 Aug 2018 14:43:58 +0100
parents 34e30a891bd3
children b1e25943a004
comparison
equal deleted inserted replaced
3232:34e30a891bd3 3233:176b537a658c
21 21
22 module:log("debug", "Getting private bookmarks: %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);
27 local ok, id, item = service:get_last_item("storage:bookmarks", session.full_jid); 26 local ok, id, item = service:get_last_item("storage:bookmarks", session.full_jid);
28 if not ok then 27 if not ok then
29 module:log("error", "Failed to retrieve PEP bookmarks of %s: %s", username, id); 28 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")); 29 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to retrive bookmarks from PEP"));
31 return; 30 return;
32 end 31 end
32 if not id or not item then
33 module:log("debug", "Got no PEP bookmarks item for %s, returning empty private bookmarks", username);
34 session.send(st.reply(stanza):add_child(query));
35 return
36 end
37 module:log("debug", "Got item %s: %s", id, item);
33 38
34 local content = item.tags[1]; 39 local content = item.tags[1];
35 module:log("debug", "Sending back private for %s: %s", username, content); 40 module:log("debug", "Sending back private for %s: %s", username, content);
36 session.send(st.reply(stanza):query("jabber:iq:private"):add_child(content)); 41 session.send(st.reply(stanza):query("jabber:iq:private"):add_child(content));
37 return true; 42 return true;