fix: use try_from for i64/u64 casts; split format_notification into helpers

This commit is contained in:
damocles 2026-05-22 19:09:03 +02:00
parent 484cea62c7
commit bbe2112dc9
3 changed files with 168 additions and 141 deletions

View file

@ -609,13 +609,13 @@ impl Broker {
/// in the last `since_secs` seconds (0 = all reminders).
pub fn reminder_rollup_for(&self, agent: &str, since_secs: u64) -> Result<hive_sh4re::ReminderStats> {
let conn = self.conn.lock().unwrap();
#[allow(clippy::cast_possible_wrap)] // unix epoch secs fit in i64 until year 292B
let cutoff_time = if since_secs > 0 {
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.ok()
.map_or(0, |d| d.as_secs() as i64);
now - since_secs as i64
.and_then(|d| i64::try_from(d.as_secs()).ok())
.unwrap_or(0);
now.saturating_sub(i64::try_from(since_secs).unwrap_or(i64::MAX))
} else {
i64::MIN
};