An administrator picks sections, a schedule (daily, weekly or monthly, at a time in a time zone) and recipients, who must be accounts on this server. Every node looks for due reports once a minute; a run is claimed with the task lock, keyed by report and due time, and recorded on the report, so it goes once. The report is built from what the server already keeps: mail flow, the queue, spoofing from received DMARC reports, TLS failures, deliverability findings and what changed since the last run, security counters, people near their quota, and expiring certificates. It is mailed as text and HTML with optional CSV attachments, DKIM-signed; a sender domain without a key fails the run with that reason instead of sending unsigned. The weekly digest is a built-in report on every server, on by default: every section, Mondays 07:00 UTC, to the system administrators. It can be changed or turned off, not deleted. A tenant administrator makes and sees only their own tenant's reports, which leave out server-wide sections. New: inbuxa:ScheduledReport and inbuxa:ScheduledReportSettings, the sysScheduledReportGet and sysScheduledReportUpdate permissions (granted once to existing administrator roles), privacy catalog entries, and a system test. Spec: inbuxa-drafts specs/scheduled-reports.md.
78 lines
2.1 KiB
Rust
78 lines
2.1 KiB
Rust
/*
|
|
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
|
*
|
|
* Modified by Coffey Labs in 2026 for INBUXA.
|
|
*/
|
|
|
|
use common::config::smtp::report::AggregateFrequency;
|
|
use mail_parser::DateTime;
|
|
use std::time::SystemTime;
|
|
|
|
pub mod analysis;
|
|
pub mod dkim;
|
|
pub mod dmarc;
|
|
pub mod inbound;
|
|
pub mod index;
|
|
pub mod inbuxa_send; // inbuxa: signed server-built mail (scheduled-reports spec, RP-14)
|
|
pub mod scheduler;
|
|
pub mod send;
|
|
pub mod shared; // inbuxa: reports written by every node
|
|
pub mod spf;
|
|
pub mod tls;
|
|
|
|
pub trait AggregateTimestamp {
|
|
fn to_timestamp(&self) -> u64;
|
|
fn to_timestamp_(&self, dt: DateTime) -> u64;
|
|
fn as_secs(&self) -> u64;
|
|
fn due(&self) -> u64;
|
|
}
|
|
|
|
impl AggregateTimestamp for AggregateFrequency {
|
|
fn to_timestamp(&self) -> u64 {
|
|
self.to_timestamp_(DateTime::from_timestamp(
|
|
SystemTime::now()
|
|
.duration_since(SystemTime::UNIX_EPOCH)
|
|
.map_or(0, |d| d.as_secs()) as i64,
|
|
))
|
|
}
|
|
|
|
fn to_timestamp_(&self, mut dt: DateTime) -> u64 {
|
|
(match self {
|
|
AggregateFrequency::Hourly => {
|
|
dt.minute = 0;
|
|
dt.second = 0;
|
|
dt.to_timestamp()
|
|
}
|
|
AggregateFrequency::Daily => {
|
|
dt.hour = 0;
|
|
dt.minute = 0;
|
|
dt.second = 0;
|
|
dt.to_timestamp()
|
|
}
|
|
AggregateFrequency::Weekly => {
|
|
let dow = dt.day_of_week();
|
|
dt.hour = 0;
|
|
dt.minute = 0;
|
|
dt.second = 0;
|
|
dt.to_timestamp() - (86400 * dow as i64)
|
|
}
|
|
AggregateFrequency::Never => dt.to_timestamp(),
|
|
}) as u64
|
|
}
|
|
|
|
fn as_secs(&self) -> u64 {
|
|
match self {
|
|
AggregateFrequency::Hourly => 3600,
|
|
AggregateFrequency::Daily => 86400,
|
|
AggregateFrequency::Weekly => 7 * 86400,
|
|
AggregateFrequency::Never => 0,
|
|
}
|
|
}
|
|
|
|
fn due(&self) -> u64 {
|
|
self.to_timestamp() + self.as_secs()
|
|
}
|
|
}
|