From 3fea2d03959d4d3a8edcfc1d7cae226923ec0b2e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 10 May 2022 13:14:27 +0200 Subject: [PATCH] Allow is_delay_ok_since_last_notification_sent? to have the delay as param Signed-off-by: Thomas Citharel --- lib/service/date_time/date_time.ex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/service/date_time/date_time.ex b/lib/service/date_time/date_time.ex index 102a4c504..bccf9e7d0 100644 --- a/lib/service/date_time/date_time.ex +++ b/lib/service/date_time/date_time.ex @@ -205,9 +205,12 @@ defmodule Mobilizon.Service.DateTime do is_first_day_of_week(compare_to_day, locale) && is_between_hours?(options) end - @spec is_delay_ok_since_last_notification_sent?(DateTime.t()) :: boolean() - def is_delay_ok_since_last_notification_sent?(%DateTime{} = last_notification_sent) do - DateTime.compare(DateTime.add(last_notification_sent, 3_600), DateTime.utc_now()) == + @spec is_delay_ok_since_last_notification_sent?(DateTime.t(), pos_integer()) :: boolean() + def is_delay_ok_since_last_notification_sent?( + %DateTime{} = last_notification_sent, + delay \\ 3_600 + ) do + DateTime.compare(DateTime.add(last_notification_sent, delay), DateTime.utc_now()) == :lt end