Comparison

mod_bookmarks2/mod_bookmarks2.lua @ 4719:5a06c711649c

mod_bookmarks2: Use max_items='max' on trunk, with fallback check_node_config() throws an error attempting to compare the pep_max_items number with the 'max' string, which allows detecting and support using 'max' where available. Unsure what happens when you upgrade, that seems a problem for a future commit! :)
author Kim Alvefur <zash@zash.se>
date Wed, 20 Oct 2021 22:16:14 +0200
parent 4688:05725276fac0
child 4738:5aee8d86629a
comparison
equal deleted inserted replaced
4718:6e3254e13fb7 4719:5a06c711649c
12 local namespace = "urn:xmpp:bookmarks:1"; 12 local namespace = "urn:xmpp:bookmarks:1";
13 13
14 local default_options = { 14 local default_options = {
15 ["persist_items"] = true; 15 ["persist_items"] = true;
16 -- This should be much higher, the XEP recommends 10000 but mod_pep rejects that. 16 -- This should be much higher, the XEP recommends 10000 but mod_pep rejects that.
17 ["max_items"] = module:get_option_number("pep_max_items", 256); 17 ["max_items"] = "max";
18 ["send_last_published_item"] = "never"; 18 ["send_last_published_item"] = "never";
19 ["access_model"] = "whitelist"; 19 ["access_model"] = "whitelist";
20 }; 20 };
21
22 if not pcall(mod_pep.check_node_config, nil, nil, default_options) then
23 -- 0.11 or earlier not supporting max_items="max" trows an error here
24 module:log("debug", "Setting max_items=pep_max_items because 'max' is not supported in this version");
25 default_options["max_items"] = module:get_option_number("pep_max_items", 256);
26 end
21 27
22 module:hook("account-disco-info", function (event) 28 module:hook("account-disco-info", function (event)
23 -- This Time it’s Serious! 29 -- This Time it’s Serious!
24 event.reply:tag("feature", { var = namespace.."#compat" }):up(); 30 event.reply:tag("feature", { var = namespace.."#compat" }):up();
25 end); 31 end);