# HG changeset patch # User Menel # Date 1773180418 -3600 # Node ID 1932fd38d3534bda22f7b3b4d29de3e5f1d524dd # Parent 9a89cb9810a71375e3846effb48fb63b08608158 mod_muc_restrict_attention: logging configurable and to debug by default. diff -r 9a89cb9810a7 -r 1932fd38d353 mod_muc_restrict_attention/README.md --- 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 diff -r 9a89cb9810a7 -r 1932fd38d353 mod_muc_restrict_attention/mod_muc_restrict_attention.lua --- 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