Diff

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
parent 12593:1832b6c9c6ed
child 13547:d6545c533ce2
line wrap: on
line diff
--- a/plugins/mod_bookmarks.lua	Sat Nov 02 18:10:25 2024 +0100
+++ b/plugins/mod_bookmarks.lua	Fri Nov 08 10:24:42 2024 +0000
@@ -167,10 +167,15 @@
 		if synchronise then
 			-- If we set zero legacy bookmarks, purge the bookmarks 2 node.
 			module:log("debug", "No bookmark in the set, purging instead.");
-			return service:purge(namespace, jid, true);
-		else
-			return true;
+			local ok, err = service:purge(namespace, jid, true);
+			-- It's okay if no node exists when purging, user has
+			-- no bookmarks anyway.
+			if not ok and err ~= "item-not-found" then
+				module:log("error", "Failed to clear items from bookmarks 2 node: %s", err);
+				return ok, err;
+			end
 		end
+		return true;
 	end
 
 	-- Retrieve the current bookmarks2.