# HG changeset patch # User Matthew Wild # Date 1585913216 -3600 # Node ID 2b10e51d85a6fcd3aa8964057c80a9a92b5303bd # Parent 15355caf4553fcf4cbb16a87df412882b4352924 mod_muc_limits: Add config option to limit to join stanzas only This is a bit more limited in pre-0.11 MUC modules, because it just detects stanzas sent to full JIDs (which would include all presence and nick changes). This option is useful for setups where users are typically unaffiliated, but trusted (e.g. if access to the room is gated through some other means such as password/token auth). diff -r 15355caf4553 -r 2b10e51d85a6 mod_muc_limits/mod_muc_limits.lua --- a/mod_muc_limits/mod_muc_limits.lua Fri Apr 03 12:24:54 2020 +0100 +++ b/mod_muc_limits/mod_muc_limits.lua Fri Apr 03 12:26:56 2020 +0100 @@ -13,6 +13,7 @@ local burst = math.max(module:get_option_number("muc_burst_factor", 6), 1); local max_nick_length = module:get_option_number("muc_max_nick_length", 23); -- Default chosen through scientific methods +local join_only = module:get_option_boolean("muc_limit_joins_only", false); local dropped_count = 0; local dropped_jids; @@ -79,12 +80,16 @@ end end - module:hook("message/bare", handle_stanza, 501); - module:hook("message/full", handle_stanza, 501); - module:hook("presence/bare", handle_stanza, 501); module:hook("presence/full", handle_stanza, 501); + if not join_only then + module:hook("message/bare", handle_stanza, 501); + module:hook("message/full", handle_stanza, 501); + module:hook("presence/bare", handle_stanza, 501); + end else module:hook("muc-occupant-pre-join", handle_stanza); - module:hook("muc-occupant-pre-change", handle_stanza); - module:hook("muc-occupant-groupchat", handle_stanza); + if not join_only then + module:hook("muc-occupant-pre-change", handle_stanza); + module:hook("muc-occupant-groupchat", handle_stanza); + end end