aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-10-20 17:32:34 +0200
committerKim Alvefur <zash@zash.se>2021-10-20 17:32:34 +0200
commit5016e666403899202ad8b5775761325ee98cf3b8 (patch)
tree3501ad5624c12e623e68f47c824b366655cbf3bd
parent8b769c373d076ea0a678680ef187f83cd0e7d19d (diff)
downloadprosody-5016e666403899202ad8b5775761325ee98cf3b8.tar.gz
prosody-5016e666403899202ad8b5775761325ee98cf3b8.zip
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.
-rw-r--r--plugins/mod_pep.lua7
-rw-r--r--plugins/mod_pubsub/mod_pubsub.lua7
-rw-r--r--spec/scansion/pubsub_config.scs4
-rw-r--r--spec/scansion/pubsub_max_items.scs2
-rw-r--r--spec/scansion/pubsub_multi_items.scs2
-rw-r--r--spec/scansion/pubsub_preconditions.scs4
6 files changed, 20 insertions, 6 deletions
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
diff --git a/spec/scansion/pubsub_config.scs b/spec/scansion/pubsub_config.scs
index de3f47da..d06d864e 100644
--- a/spec/scansion/pubsub_config.scs
+++ b/spec/scansion/pubsub_config.scs
@@ -49,7 +49,7 @@ Romeo receives:
<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 @@ Romeo sends:
<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>
diff --git a/spec/scansion/pubsub_max_items.scs b/spec/scansion/pubsub_max_items.scs
index ae106edd..c5525bd3 100644
--- a/spec/scansion/pubsub_max_items.scs
+++ b/spec/scansion/pubsub_max_items.scs
@@ -44,7 +44,7 @@ Alice receives:
<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>
diff --git a/spec/scansion/pubsub_multi_items.scs b/spec/scansion/pubsub_multi_items.scs
index d8a9536a..e43bc839 100644
--- a/spec/scansion/pubsub_multi_items.scs
+++ b/spec/scansion/pubsub_multi_items.scs
@@ -44,7 +44,7 @@ Alice receives:
<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>
diff --git a/spec/scansion/pubsub_preconditions.scs b/spec/scansion/pubsub_preconditions.scs
index bcf83219..5c0c2569 100644
--- a/spec/scansion/pubsub_preconditions.scs
+++ b/spec/scansion/pubsub_preconditions.scs
@@ -48,7 +48,7 @@ Romeo receives:
<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 @@ Romeo sends:
<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>