Software /
code /
prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 9100:e01c7d0cbbf4
mod_pubsub: Add configurable maximum on number of items
Like aefb96a52f5f
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 04 Aug 2018 03:13:55 +0200 |
parent | 9045:4336a2b97aba |
child | 9101:1ff694534e98 |
comparison
equal
deleted
inserted
replaced
9099:974b25c27f24 | 9100:e01c7d0cbbf4 |
---|---|
66 new_stanza:body(summary); | 66 new_stanza:body(summary); |
67 end | 67 end |
68 new_stanza.attr.to = jid; | 68 new_stanza.attr.to = jid; |
69 module:send(new_stanza); | 69 module:send(new_stanza); |
70 end | 70 end |
71 end | |
72 | |
73 local max_max_items = module:get_option_number("pubsub_max_items", 256); | |
74 function check_node_config(node, actor, new_config) -- luacheck: ignore 212/actor 212/node | |
75 if (new_config["max_items"] or 1) > max_max_items then | |
76 return false; | |
77 end | |
78 return true; | |
71 end | 79 end |
72 | 80 |
73 function is_item_stanza(item) | 81 function is_item_stanza(item) |
74 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; | 82 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; |
75 end | 83 end |
220 | 228 |
221 nodestore = node_store; | 229 nodestore = node_store; |
222 itemstore = create_simple_itemstore; | 230 itemstore = create_simple_itemstore; |
223 broadcaster = simple_broadcast; | 231 broadcaster = simple_broadcast; |
224 itemcheck = is_item_stanza; | 232 itemcheck = is_item_stanza; |
233 check_node_config = check_node_config; | |
225 get_affiliation = get_affiliation; | 234 get_affiliation = get_affiliation; |
226 | 235 |
227 normalize_jid = jid_bare; | 236 normalize_jid = jid_bare; |
228 })); | 237 })); |
229 end | 238 end |