Changeset

4850:9187a7adfc39

mod_bookmarks2: Override the node configuration if it was wrong
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 06 Jan 2022 00:59:40 +0100
parents 4849:192b7aaa3888
children 4851:0ceb2f223b30
files mod_bookmarks2/mod_bookmarks2.lua
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_bookmarks2/mod_bookmarks2.lua	Wed Jan 05 21:22:13 2022 +0100
+++ b/mod_bookmarks2/mod_bookmarks2.lua	Thu Jan 06 00:59:40 2022 +0100
@@ -182,6 +182,26 @@
 	else
 		module:log("debug", "Got existing bookmarks2.");
 		bookmarks2 = ret;
+
+		local ok, err = service:get_node_config(namespace, jid);
+		if not ok then
+			module:log("error", "Retrieving bookmarks 2 node config failed: %s", err);
+			return ok, err;
+		end
+
+		local options = err;
+		for key, value in pairs(default_options) do
+			if options[key] and options[key] ~= value then
+				module:log("warn", "Overriding bookmarks 2 configuration for %s, from %s to %s", jid, options[key], value);
+				options[key] = value;
+			end
+		end
+
+		local ok, err = service:set_node_config(namespace, jid, options);
+		if not ok then
+			module:log("error", "Setting bookmarks 2 node config failed: %s", err);
+			return ok, err;
+		end
 	end
 
 	-- Get a list of all items we may want to remove.