Software /
code /
prosody
Changeset
9077:aefb96a52f5f
mod_pep: Add 'pep_max_items' option to set an upper limit, defaults to 256 (scientifically chosen)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 01 Aug 2018 19:18:31 +0100 |
parents | 9076:00d89430d77e |
children | 9078:9e339197c724 |
files | plugins/mod_pep.lua |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_pep.lua Wed Aug 01 19:18:25 2018 +0100 +++ b/plugins/mod_pep.lua Wed Aug 01 19:18:31 2018 +0100 @@ -26,6 +26,8 @@ local node_config = module:open_store("pep", "map"); local known_nodes = module:open_store("pep"); +local max_max_items = module:get_option_number("pep_max_items", 256); + function module.save() return { services = services }; end @@ -38,6 +40,12 @@ return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; end +function check_node_config(node, actor, new_config) + if (new_config["max_items"] or 1) > max_max_items then + return false; + end +end + local function subscription_presence(username, recipient) local user_bare = jid_join(username, host); local recipient_bare = jid_bare(recipient); @@ -236,6 +244,8 @@ end; normalize_jid = jid_bare; + + check_node_config = check_node_config; }); local nodes, err = known_nodes:get(username); if nodes then