Mercurial > prosody-modules
view mod_audit_user_accounts/mod_audit_user_accounts.lua @ 5951:d6a695abb33c
mod_ping_muc: Delay ping a configurable amount of time
If a server is restarting, checking immediately before it has a chance
to complete its restart and get ready would often fail, preventing the
possibility of transparent restarts as supported by Prosody's mod_muc.
Reconnecting immediately when a connection is closed for being idle, or
because the remote server is trying to reclaim some resources, is also
counter-productive as the connection may fail.
Also, if there is some Internet routing problem affecting s2s, it may
help to wait a bit before checking, in case the problem resolved itself
in the mean time.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 11 Aug 2024 16:10:24 +0200 |
parents | 628952e4ff47 |
children |
line wrap: on
line source
module:depends("audit"); -- luacheck: read globals module.audit local dt = require "util.datetime"; local jid = require "util.jid"; local st = require "util.stanza"; local function audit_basic_event(name, custom_handler) module:hook(name, function (event) local custom; if custom_handler then custom = custom_handler(event); end module:audit(jid.join(event.username, module.host), name, { session = event.session; custom = custom; }); end); end audit_basic_event("user-registered", function (event) local invite = event.validated_invite or (event.session and event.session.validated_invite); if not invite then return; end return { st.stanza( "invite-used", { xmlns = "xmpp:prosody.im/audit", token = invite.token, } ); }; end); audit_basic_event("user-deregistered-pending"); audit_basic_event("user-deregistered"); audit_basic_event("user-enabled"); audit_basic_event("user-disabled", function (event) local meta = event.meta; if not meta then return end local meta_st = st.stanza("disabled", { xmlns = "xmpp:prosody.im/audit"; reason = meta.reason; when = meta.when and dt.datetime(meta.when) or nil; }); if meta.comment then meta_st:text_tag("comment", meta.comment); end return { meta_st }; end);