Preserve channel last_used and LEVELS overrides across compaction
Some checks failed
CI / check (push) Has been cancelled

This commit is contained in:
Jean Chevronnet 2026-07-19 04:19:22 +00:00
parent ad8a3fe065
commit 75aa8bc096
No known key found for this signature in database
2 changed files with 35 additions and 0 deletions

View file

@ -1216,12 +1216,23 @@ impl Db {
let mut snapshot: Vec<Event> = self.accounts.values().cloned().map(|a| Event::AccountRegistered(Box::new(a))).collect();
for c in self.channels.values() {
snapshot.push(Event::ChannelRegistered { name: c.name.clone(), founder: c.founder.clone(), ts: c.ts });
// ChannelRegistered replays last_used back to the registration ts, so a
// channel active since registration would have its inactivity-expiry clock
// reset by every compaction (and could then be wrongly expired). Restore it.
if c.last_used > c.ts {
snapshot.push(Event::ChannelUsed { channel: c.name.clone(), ts: c.last_used });
}
if !c.lock_on.is_empty() || !c.lock_off.is_empty() {
snapshot.push(Event::ChannelMlock { name: c.name.clone(), on: c.lock_on.clone(), off: c.lock_off.clone(), params: c.lock_params.clone() });
}
for a in &c.access {
snapshot.push(Event::ChannelAccessAdd { channel: c.name.clone(), account: a.account.clone(), level: a.level.clone() });
}
// LEVELS overrides live only in c.levels; without this they reset to the
// tier defaults on every compaction.
for (cap, role) in &c.levels {
snapshot.push(Event::ChannelLevelSet { channel: c.name.clone(), cap: cap.clone(), role: role.clone() });
}
for k in &c.akick {
snapshot.push(Event::ChannelAkickAdd { channel: c.name.clone(), mask: k.mask.clone(), reason: k.reason.clone() });
}