Comparison

plugins/mod_bookmarks.lua @ 12152:0939675955f1

mod_bookmarks: Override the node configuration if it was wrong
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 06 Jan 2022 00:59:40 +0100
parent 12149:bbbf0dd90b6d
child 12155:ae5988739990
comparison
equal deleted inserted replaced
12151:669d93f1db6a 12152:0939675955f1
174 module:log("debug", "Got %s error, aborting.", ret); 174 module:log("debug", "Got %s error, aborting.", ret);
175 return false, ret; 175 return false, ret;
176 else 176 else
177 module:log("debug", "Got existing bookmarks2."); 177 module:log("debug", "Got existing bookmarks2.");
178 bookmarks2 = ret; 178 bookmarks2 = ret;
179
180 local ok, err = service:get_node_config(namespace, jid);
181 if not ok then
182 module:log("error", "Retrieving bookmarks 2 node config failed: %s", err);
183 return ok, err;
184 end
185
186 local options = err;
187 for key, value in pairs(default_options) do
188 if options[key] and options[key] ~= value then
189 module:log("warn", "Overriding bookmarks 2 configuration for %s, from %s to %s", jid, options[key], value);
190 options[key] = value;
191 end
192 end
193
194 local ok, err = service:set_node_config(namespace, jid, options);
195 if not ok then
196 module:log("error", "Setting bookmarks 2 node config failed: %s", err);
197 return ok, err;
198 end
179 end 199 end
180 200
181 -- Get a list of all items we may want to remove. 201 -- Get a list of all items we may want to remove.
182 local to_remove = {}; 202 local to_remove = {};
183 for i in ipairs(bookmarks2) do 203 for i in ipairs(bookmarks2) do