diff mod_muc_restrict_attention/mod_muc_restrict_attention.lua @ 6517:3d14a407307d

mod_muc_restrict_attention: Add default option for participants. Breaking change config option name.
author Menel <menel@snikket.de>
date Thu, 16 Apr 2026 12:02:18 +0200
parents 054691d29c25
children b66c93276534
line wrap: on
line diff
--- a/mod_muc_restrict_attention/mod_muc_restrict_attention.lua	Wed Apr 08 23:12:13 2026 +0200
+++ b/mod_muc_restrict_attention/mod_muc_restrict_attention.lua	Thu Apr 16 12:02:18 2026 +0200
@@ -3,8 +3,21 @@
 local from_affiliation
 local from_jid
 local room_jid
-local restrict_members_by_default = module:get_option_boolean("muc_restrict_attention_from_members", true)
 local loglevel = module:get_option_enum("muc_restrict_attention_loglevel", "debug", "info", "warn", "error")
+local restrict_by_default = module:get_option_enum("muc_restrict_attention_by_default", "members", "participants", false, "false")
+
+-- ugly hack, improve it when you do for the room config option too
+if restrict_by_default == "members" then
+	local restrict_members_by_default = true
+	local restrict_participants_by_default = true
+elseif restrict_by_default == false
+		or restrict_by_default == "false" then
+	local restrict_members_by_default = false
+	local restrict_participants_by_default = false 
+elseif restrict_by_default == "participants" then
+	local restrict_members_by_default = false
+	local restrict_participants_by_default = true
+end
 
 local function should_restrict_members(room)
 	local restrict_members = room._data.restrict_members
@@ -69,7 +82,8 @@
 		return
 	end
 	if should_restrict_members(event.room)
-	or not from_affiliation then
+	or restrict_participants_by_default
+	and not from_affiliation then
 		room_jid = event.room.jid
 		from_jid = event.stanza.attr.from
 		stanza:maptags(filter_attention_tags)