Mercurial > prosody-modules
view mod_admin_notify/mod_admin_notify.lua @ 5787:e79f9dec35c0
mod_c2s_conn_throttle: Reduce log level from error->info
Our general policy is that "error" should never be triggerable by remote
entities, and that it is always about something that requires admin
intervention. This satisfies neither condition.
The "warn" level can be used for unexpected events/behaviour triggered by
remote entities, and this could qualify. However I don't think failed auth
attempts are unexpected enough.
I selected "info" because it is what is also used for other notable session
lifecycle events.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 07 Dec 2023 15:46:50 +0000 |
parents | 44e18454e1e0 |
children |
line wrap: on
line source
local it = require "util.iterators"; local jid = require "util.jid"; local set = require "util.set"; local st = require "util.stanza"; local roles_store = module:open_store("roles", "map"); local config_admins = module:get_option_inherited_set("admins", {}) / jid.prep; local function append_host(username) return username.."@"..module.host; end local function get_admins() local role_admins = roles_store:get_all("prosody:admin") or {}; local admins = config_admins + (set.new(it.to_array(it.keys(role_admins))) / append_host); return admins; end function notify(text) --luacheck: ignore 131/notify local base_msg = st.message({ from = module.host }) :text_tag("body", text); for admin_jid in get_admins() do local msg = st.clone(base_msg); msg.attr.to = admin_jid; module:send(msg); end end