comparison plugins/mod_bookmarks.lua @ 13548:84ee435f284e

Merge 0.12->trunk
author Matthew Wild <mwild1@gmail.com>
date Fri, 08 Nov 2024 10:31:25 +0000
parents 74b9e05af71e d6545c533ce2
children
comparison
equal deleted inserted replaced
13545:7f05254fb042 13548:84ee435f284e
165 165
166 if #bookmarks.tags == 0 then 166 if #bookmarks.tags == 0 then
167 if synchronise then 167 if synchronise then
168 -- If we set zero legacy bookmarks, purge the bookmarks 2 node. 168 -- If we set zero legacy bookmarks, purge the bookmarks 2 node.
169 module:log("debug", "No bookmark in the set, purging instead."); 169 module:log("debug", "No bookmark in the set, purging instead.");
170 return service:purge(namespace, jid, true); 170 local ok, err = service:purge(namespace, jid, true);
171 else 171 -- It's okay if no node exists when purging, user has
172 return true; 172 -- no bookmarks anyway.
173 end 173 if not ok and err ~= "item-not-found" then
174 module:log("error", "Failed to clear items from bookmarks 2 node: %s", err);
175 return ok, err;
176 end
177 end
178 return true;
174 end 179 end
175 180
176 -- Retrieve the current bookmarks2. 181 -- Retrieve the current bookmarks2.
177 module:log("debug", "Retrieving the current bookmarks 2."); 182 module:log("debug", "Retrieving the current bookmarks 2.");
178 local has_bookmarks2, ret = service:get_items(namespace, jid); 183 local has_bookmarks2, ret = service:get_items(namespace, jid);
307 312
308 module:log("debug", "Legacy PEP bookmarks set by client, publishing to PEP."); 313 module:log("debug", "Legacy PEP bookmarks set by client, publishing to PEP.");
309 314
310 local ok, err = publish_to_pep(session.full_jid, bookmarks, true); 315 local ok, err = publish_to_pep(session.full_jid, bookmarks, true);
311 if not ok then 316 if not ok then
312 module:log("error", "Failed to publish to PEP bookmarks for %s@%s: %s", session.username, session.host, err); 317 module:log("error", "Failed to sync legacy bookmarks to PEP for %s@%s: %s", session.username, session.host, err);
313 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to store bookmarks to PEP")); 318 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to store bookmarks to PEP"));
314 return true; 319 return true;
315 end 320 end
316 321
317 session.send(st.reply(stanza)); 322 session.send(st.reply(stanza));
333 338
334 module:log("debug", "Private bookmarks set by client, publishing to PEP."); 339 module:log("debug", "Private bookmarks set by client, publishing to PEP.");
335 340
336 local ok, err = publish_to_pep(session.full_jid, bookmarks, true); 341 local ok, err = publish_to_pep(session.full_jid, bookmarks, true);
337 if not ok then 342 if not ok then
338 module:log("error", "Failed to publish to PEP bookmarks for %s@%s: %s", session.username, session.host, err); 343 module:log("error", "Failed to sync private XML bookmarks to PEP for %s@%s: %s", session.username, session.host, err);
339 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to store bookmarks to PEP")); 344 session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to store bookmarks to PEP"));
340 return true; 345 return true;
341 end 346 end
342 347
343 session.send(st.reply(stanza)); 348 session.send(st.reply(stanza));