comparison mod_bookmarks2/mod_bookmarks2.lua @ 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 5001104f0275
children a1181413a0eb
comparison
equal deleted inserted replaced
4849:192b7aaa3888 4850:9187a7adfc39
180 module:log("debug", "Got %s error, aborting.", ret); 180 module:log("debug", "Got %s error, aborting.", ret);
181 return false, ret; 181 return false, ret;
182 else 182 else
183 module:log("debug", "Got existing bookmarks2."); 183 module:log("debug", "Got existing bookmarks2.");
184 bookmarks2 = ret; 184 bookmarks2 = ret;
185
186 local ok, err = service:get_node_config(namespace, jid);
187 if not ok then
188 module:log("error", "Retrieving bookmarks 2 node config failed: %s", err);
189 return ok, err;
190 end
191
192 local options = err;
193 for key, value in pairs(default_options) do
194 if options[key] and options[key] ~= value then
195 module:log("warn", "Overriding bookmarks 2 configuration for %s, from %s to %s", jid, options[key], value);
196 options[key] = value;
197 end
198 end
199
200 local ok, err = service:set_node_config(namespace, jid, options);
201 if not ok then
202 module:log("error", "Setting bookmarks 2 node config failed: %s", err);
203 return ok, err;
204 end
185 end 205 end
186 206
187 -- Get a list of all items we may want to remove. 207 -- Get a list of all items we may want to remove.
188 local to_remove = {}; 208 local to_remove = {};
189 for i in ipairs(bookmarks2) do 209 for i in ipairs(bookmarks2) do