From 5016e666403899202ad8b5775761325ee98cf3b8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 20 Oct 2021 17:32:34 +0200 Subject: mod_pubsub,mod_pep: Advertise maximum number of items via XEP-0122 Clients would generally be using the "max" symbol instead of discovering this, but this also gets us validation and earlier rejection of out of bounds values. --- plugins/mod_pep.lua | 7 +++++++ plugins/mod_pubsub/mod_pubsub.lua | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index 93342e09..ad69e6ad 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -41,6 +41,13 @@ local function tonumber_max_items(n) return tonumber(n); end +for _, field in ipairs(lib_pubsub.node_config_form) do + if field.var == "pubsub#max_items" then + field.range_max = max_max_items; + break; + end +end + function module.save() return { services = services; diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index 09d1ab35..ed895cf4 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -48,6 +48,13 @@ local function tonumber_max_items(n) return tonumber(n); end +for _, field in ipairs(lib_pubsub.node_config_form) do + if field.var == "pubsub#max_items" then + field.range_max = max_max_items; + break; + end +end + local node_store = module:open_store(module.name.."_nodes"); local function create_simple_itemstore(node_config, node_name) --> util.cache like object -- cgit v1.2.3