engine: persist the incident ring (LOGSEARCH) across restarts via a periodic + on-shutdown snapshot event, mirroring stat-counter persistence
All checks were successful
CI / check (push) Successful in 3m44s

This commit is contained in:
Jean Chevronnet 2026-07-19 00:46:14 +00:00
parent 754c5d9e95
commit a10662bbc6
No known key found for this signature in database
9 changed files with 102 additions and 6 deletions

View file

@ -158,6 +158,14 @@ pub enum Event {
#[serde(default)]
channels: super::ChanStats,
},
// A snapshot of the recent-incident ring (OperServ LOGSEARCH), flushed
// periodically and on shutdown so the moderation trail survives a restart.
// `seq` restores the id counter; incidents are (id, ts, summary), oldest first.
IncidentsSet {
// NOT `seq`: the event flattens into LogEntry, which already has a `seq`.
incident_seq: u64,
incidents: Vec<(String, u64, String)>,
},
}
// Whether an event replicates across the federation. Account identity is Global
@ -268,7 +276,8 @@ impl Event {
| Event::ChannelOperNoteSet { .. }
| Event::JupeAdded { .. }
| Event::JupeRemoved { .. }
| Event::StatsSet { .. } => Scope::Local,
| Event::StatsSet { .. }
| Event::IncidentsSet { .. } => Scope::Local,
}
}
}
@ -689,6 +698,10 @@ pub(crate) fn apply(accounts: &mut HashMap<String, Account>, channels: &mut Hash
net.stats = counters.into_iter().collect();
net.chan_stats = channels;
}
Event::IncidentsSet { incident_seq, incidents } => {
net.incident_seq = incident_seq;
net.incidents = incidents;
}
Event::AccountExpiryWarned { account } => {
if let Some(a) = accounts.get_mut(&key(&account)) {
a.expiry_warned = true;