From bb1c61d0b9876f429aafa8217445e8d04a68f8c8 Mon Sep 17 00:00:00 2001 From: jude Date: Tue, 20 Jun 2023 14:44:05 +0100 Subject: [PATCH] Fallback for reminder days --- postman/src/sender.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/postman/src/sender.rs b/postman/src/sender.rs index 1bfd6af..cff5c86 100644 --- a/postman/src/sender.rs +++ b/postman/src/sender.rs @@ -345,7 +345,10 @@ WHERE } async fn refresh(&self, pool: impl Executor<'_, Database = Database> + Copy) { - if self.interval_seconds.is_some() || self.interval_months.is_some() { + if self.interval_seconds.is_some() + || self.interval_months.is_some() + || self.interval_days.is_some() + { let now = Utc::now(); let mut updated_reminder_time = self.utc_time.with_timezone(&self.timezone.parse().unwrap_or(Tz::UTC)); @@ -365,9 +368,11 @@ WHERE updated_reminder_time = updated_reminder_time .checked_add_days(Days::new(interval as u64)) .unwrap_or_else(|| { - warn!("Could not add days to a reminder"); + warn!( + "Could not add days to a reminder. Falling back to naive addition" + ); - updated_reminder_time + updated_reminder_time + 86400 * interval }); }