comparison plugins/mod_bookmarks.lua @ 13546:1a915c2e0fa4 0.12

mod_bookmarks: Suppress error publishing empty legacy bookmarks w/ no PEP node It appears that when: 1) The user has no bookmarks 2 node in PEP 2) The client publishes an empty bookmark set to a legacy bookmarks location 3) mod_bookmarks will attempt to purge items from the non-existent node and log an error about the failure (item-not-found). This new code will suppress an item-not-found error from the purge operation in the empty-bookmarks case, and adds a log message for any other error (this is helpful because the existing log message confusingly says it was an error *publishing* to the node, which isn't always accurate).
author Matthew Wild <mwild1@gmail.com>
date Fri, 08 Nov 2024 10:24:42 +0000
parents 1832b6c9c6ed
children d6545c533ce2
comparison
equal deleted inserted replaced
13543:01d2abc3d17c 13546:1a915c2e0fa4
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);