diff mod_muc_restrict_attention/mod_muc_restrict_attention.lua @ 6428:23e3edb6f9ea

mod_muc_restrict_attention: Change logic:, always disallow unaffiliated, always allow admin and owner and make it configurable for members. Also it actually works O_o.
author Menel <menel@snikket.de>
date Tue, 10 Mar 2026 14:24:07 +0100
parents d748985de48f
children 66d7da6a9032
line wrap: on
line diff
--- a/mod_muc_restrict_attention/mod_muc_restrict_attention.lua	Tue Mar 10 12:18:08 2026 +0100
+++ b/mod_muc_restrict_attention/mod_muc_restrict_attention.lua	Tue Mar 10 14:24:07 2026 +0100
@@ -1,6 +1,6 @@
 module:depends"muc";
 
-local restrict_by_default = module:get_option_boolean("muc_room_default_restrict_attention", true);
+local restrict_by_default = module:get_option_boolean("muc_restrict_attention_from_members", true);
 
 local function should_restrict_attention(room)
 	local restrict_attention = room._data.restrict_attention;
@@ -15,7 +15,7 @@
 	table.insert(form, {
 		name = "{xmpp:prosody.im}muc#roomconfig_unaffiliated_attention",
 		type = "boolean",
-		label = "Allow \"XEP-0224: Attention\" from non-members",
+		label = "Allow \"XEP-0224: Attention\" from members",
 		value = not should_restrict_attention(room),
 	});
 end);
@@ -58,9 +58,13 @@
 
 module:hook("muc-occupant-groupchat", function (event)
 	local stanza = event.stanza;
-	if stanza.attr.type ~= "groupchat" then return; end
-	if event.room:get_affiliation(stanza.attr.from) then return end
-	if should_restrict_attention(event.room) then
+	if stanza.attr.type ~= "groupchat" then return; end -- not relevant
+	if event.room:get_affiliation(stanza.attr.from) == 'admin'
+		or event.room:get_affiliation(stanza.attr.from) == 'owner' then
+		return
+	end
+	if should_restrict_attention(event.room)
+		or not event.room:get_affiliation(stanza.attr.from) then
 		stanza:maptags(filter_attention_tags);
-	end
-end, 20);
+ 	end
+end, 9);