Changeset

11856:14a679588b7b

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.
author Kim Alvefur <zash@zash.se>
date Wed, 20 Oct 2021 17:32:34 +0200
parents 11855:8890eaa69446
children 11857:e080d6aa0b3b
files plugins/mod_pep.lua plugins/mod_pubsub/mod_pubsub.lua spec/scansion/pubsub_config.scs spec/scansion/pubsub_max_items.scs spec/scansion/pubsub_multi_items.scs spec/scansion/pubsub_preconditions.scs
diffstat 6 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pep.lua	Wed Oct 20 17:31:24 2021 +0200
+++ b/plugins/mod_pep.lua	Wed Oct 20 17:32:34 2021 +0200
@@ -41,6 +41,13 @@
 	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;
--- a/plugins/mod_pubsub/mod_pubsub.lua	Wed Oct 20 17:31:24 2021 +0200
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Wed Oct 20 17:32:34 2021 +0200
@@ -48,6 +48,13 @@
 	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
--- a/spec/scansion/pubsub_config.scs	Wed Oct 20 17:31:24 2021 +0200
+++ b/spec/scansion/pubsub_config.scs	Wed Oct 20 17:32:34 2021 +0200
@@ -49,7 +49,7 @@
 					<field var="pubsub#type" label="The type of node data, usually specified by the namespace of the payload (if any)" type="text-single"/>
 					<field var="pubsub#max_items" label="Max # of items to persist" type="text-single">
 						<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max">
-							<range min="1"/>
+							<range min="1" max="256"/>
 						</validate>
 						<value>1</value>
 					</field>
@@ -139,7 +139,7 @@
 					<field var="pubsub#type" type="text-single" label="The type of node data, usually specified by the namespace of the payload (if any)"/>
 					<field var="pubsub#max_items" type="text-single" label="Max # of items to persist">
 						<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max">
-							<range min="1"/>
+							<range min="1" max="256"/>
 						</validate>
 						<value>1</value>
 					</field>
--- a/spec/scansion/pubsub_max_items.scs	Wed Oct 20 17:31:24 2021 +0200
+++ b/spec/scansion/pubsub_max_items.scs	Wed Oct 20 17:32:34 2021 +0200
@@ -44,7 +44,7 @@
 		<field var="pubsub#type" label="The type of node data, usually specified by the namespace of the payload (if any)" type="text-single"/>
 		<field var="pubsub#max_items" label="Max # of items to persist" type="text-single">
 			<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max">
-				<range min="1"/>
+				<range min="1" max="256"/>
 			</validate>
 		  <value>20</value>
 		</field>
--- a/spec/scansion/pubsub_multi_items.scs	Wed Oct 20 17:31:24 2021 +0200
+++ b/spec/scansion/pubsub_multi_items.scs	Wed Oct 20 17:32:34 2021 +0200
@@ -44,7 +44,7 @@
 		<field var="pubsub#type" label="The type of node data, usually specified by the namespace of the payload (if any)" type="text-single"/>
 		<field var="pubsub#max_items" label="Max # of items to persist" type="text-single">
 			<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max">
-				<range min="1"/>
+				<range min="1" max="256"/>
 			</validate>
 		  <value>20</value>
 		</field>
--- a/spec/scansion/pubsub_preconditions.scs	Wed Oct 20 17:31:24 2021 +0200
+++ b/spec/scansion/pubsub_preconditions.scs	Wed Oct 20 17:32:34 2021 +0200
@@ -48,7 +48,7 @@
 					<field var="pubsub#type" label="The type of node data, usually specified by the namespace of the payload (if any)" type="text-single"/>
 					<field var="pubsub#max_items" label="Max # of items to persist" type="text-single">
 						<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max">
-							<range min="1"/>
+							<range min="1" max="256"/>
 						</validate>
 						<value>1</value>
 					</field>
@@ -138,7 +138,7 @@
 					<field var="pubsub#type" type="text-single" label="The type of node data, usually specified by the namespace of the payload (if any)"/>
 					<field var="pubsub#max_items" type="text-single" label="Max # of items to persist">
 						<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max">
-							<range min="1"/>
+							<range min="1" max="256"/>
 						</validate>
 						<value>1</value>
 					</field>