Allow is_delay_ok_since_last_notification_sent? to have the delay as

param

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-05-10 13:14:27 +02:00
parent 44b2ca26bd
commit 3fea2d0395
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -205,9 +205,12 @@ defmodule Mobilizon.Service.DateTime do
is_first_day_of_week(compare_to_day, locale) && is_between_hours?(options) is_first_day_of_week(compare_to_day, locale) && is_between_hours?(options)
end end
@spec is_delay_ok_since_last_notification_sent?(DateTime.t()) :: boolean() @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) do def is_delay_ok_since_last_notification_sent?(
DateTime.compare(DateTime.add(last_notification_sent, 3_600), DateTime.utc_now()) == %DateTime{} = last_notification_sent,
delay \\ 3_600
) do
DateTime.compare(DateTime.add(last_notification_sent, delay), DateTime.utc_now()) ==
:lt :lt
end end