changeset 3965:2b10e51d85a6

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).
author Matthew Wild <mwild1@gmail.com>
date Fri, 03 Apr 2020 12:26:56 +0100
parents 15355caf4553
children bf5d91769f99
files mod_muc_limits/mod_muc_limits.lua
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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