From 8f8de0403bab0a819420db69bb44bdb2a474d137 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Fri, 20 Aug 2021 20:30:11 +0200 Subject: [PATCH] PubSub: Support 'max_items=max' node configuration Let clients request the maximum limit for the node configuration option 'max_items' by specifying the special value 'max' instead of an integer. This was added to XEP-0060, revision 1.17.0 (and clarified in revision 1.20.0). Thanks to Ammonit Measurement GmbH for sponsoring this work. --- mix.exs | 2 +- rebar.config | 2 +- src/mod_pubsub.erl | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index c33710b45..0b5d40b09 100644 --- a/mix.exs +++ b/mix.exs @@ -124,7 +124,7 @@ defmodule Ejabberd.MixProject do {:pkix, "~> 1.0"}, {:stringprep, ">= 1.0.26"}, {:stun, "~> 1.0"}, - {:xmpp, "~> 1.5"}, + {:xmpp, git: "https://github.com/processone/xmpp", ref: "e943c0285aa85e3cbd4bfb9259f6b7de32b00395", override: true}, {:yconf, "~> 1.0"}] ++ cond_deps() end diff --git a/rebar.config b/rebar.config index 798e6350b..a70ccfba3 100644 --- a/rebar.config +++ b/rebar.config @@ -59,7 +59,7 @@ {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.27"}}}, {if_var_true, stun, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.44"}}}}, - {xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.5.4"}}}, + {xmpp, ".*", {git, "https://github.com/processone/xmpp", "e943c0285aa85e3cbd4bfb9259f6b7de32b00395"}}, {yconf, ".*", {git, "https://github.com/processone/yconf", {tag, "1.0.12"}}} ]}. diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index d49a11817..49a54c9b4 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -3553,8 +3553,10 @@ decode_get_pending(#xdata{fields = Fs}, Lang) -> check_opt_range(_Opt, _Opts, undefined) -> true; check_opt_range(Opt, Opts, Max) -> - Val = proplists:get_value(Opt, Opts, Max), - Val =< Max. + case proplists:get_value(Opt, Opts, Max) of + max -> true; + Val -> Val =< Max + end. -spec get_max_items_node(host()) -> undefined | non_neg_integer(). get_max_items_node(Host) -> @@ -3708,6 +3710,7 @@ features() -> <<"access-whitelist">>, % OPTIONAL <<"collections">>, % RECOMMENDED <<"config-node">>, % RECOMMENDED + <<"config-node-max">>, <<"create-and-configure">>, % RECOMMENDED <<"item-ids">>, % RECOMMENDED <<"last-published">>, % RECOMMENDED