# HG changeset patch # User Kim Alvefur # Date 1533345235 -7200 # Node ID e01c7d0cbbf4e897f516a246435cd55359c496b7 # Parent 974b25c27f24b7c3af3ce08d4ea2c7f5a48eb975 mod_pubsub: Add configurable maximum on number of items Like aefb96a52f5f diff -r 974b25c27f24 -r e01c7d0cbbf4 plugins/mod_pubsub/mod_pubsub.lua --- a/plugins/mod_pubsub/mod_pubsub.lua Sat Aug 04 03:13:26 2018 +0200 +++ b/plugins/mod_pubsub/mod_pubsub.lua Sat Aug 04 03:13:55 2018 +0200 @@ -70,6 +70,14 @@ end end +local max_max_items = module:get_option_number("pubsub_max_items", 256); +function check_node_config(node, actor, new_config) -- luacheck: ignore 212/actor 212/node + if (new_config["max_items"] or 1) > max_max_items then + return false; + end + return true; +end + function is_item_stanza(item) return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; end @@ -222,6 +230,7 @@ itemstore = create_simple_itemstore; broadcaster = simple_broadcast; itemcheck = is_item_stanza; + check_node_config = check_node_config; get_affiliation = get_affiliation; normalize_jid = jid_bare;