changeset 6434:1932fd38d353

mod_muc_restrict_attention: logging configurable and to debug by default.
author Menel <menel@snikket.de>
date Tue, 10 Mar 2026 23:06:58 +0100
parents 9a89cb9810a7
children 4c79399e9bc8
files mod_muc_restrict_attention/README.md mod_muc_restrict_attention/mod_muc_restrict_attention.lua
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_restrict_attention/README.md	Tue Mar 10 20:37:04 2026 +0100
+++ b/mod_muc_restrict_attention/README.md	Tue Mar 10 23:06:58 2026 +0100
@@ -26,10 +26,13 @@
 
 ## Settings
 
-A default setting can be provided in the config file, **defaults to true**:
+A default setting can be provided in the config file, **defaults to true**
+A loglevel can be set (debug, info, warn, error)
+Defaults to *debug*: 
 
 ``` {.lua}
 muc_restrict_attention_from_members = true
+muc_restrict_attention_loglevel = "debug"
 ```
 
 # Todo
--- a/mod_muc_restrict_attention/mod_muc_restrict_attention.lua	Tue Mar 10 20:37:04 2026 +0100
+++ b/mod_muc_restrict_attention/mod_muc_restrict_attention.lua	Tue Mar 10 23:06:58 2026 +0100
@@ -1,7 +1,11 @@
 module:depends"muc"
 
+local from_affiliation
+local from_jid
+local room_jid
 local restrict_by_default = module:get_option_boolean("muc_restrict_attention_from_members", true)
-local from_affiliation --need it at the end
+local loglevel = module:get_option_enum("muc_restrict_attention_loglevel", "debug", "info", "warn", "error")
+
 local function should_restrict_attention(room)
 	local restrict_attention = room._data.restrict_attention
 	if restrict_attention == nil then
@@ -50,7 +54,7 @@
 local function filter_attention_tags(tag)
 	local xmlns = tag.attr.xmlns
 	if xmlns == "urn:xmpp:attention:0" then
-		module:log("info", "Stripped \"Attention\" from a message, affiliation: %s", from_affiliation)
+		module:log(loglevel, "Stripped \"Attention\" from %q, affiliation: %q in %q", from_jid, from_affiliation, room_jid)
 		return nil
 	end
 	return tag
@@ -59,13 +63,15 @@
 module:hook("muc-occupant-groupchat", function (event)
 	local stanza = event.stanza
 	from_affiliation = event.room:get_affiliation(stanza.attr.from) 
-	if stanza.attr.type ~= "groupchat" then return; end -- return since not relevant stanza
+	if stanza.attr.type ~= "groupchat" then return; end 
 	if from_affiliation == "admin"
 	or from_affiliation == "owner" then
 		return
 	end
 	if should_restrict_attention(event.room)
 	or not from_affiliation then
+		room_jid = event.room.jid
+		from_jid = event.stanza.attr.from
 		stanza:maptags(filter_attention_tags)
 	end
 end, 9) --unsure what priority is sensible