Allow is_delay_ok_since_last_notification_sent? to have the delay as

param

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
chapril
Thomas Citharel 7 months ago
parent 44b2ca26bd
commit 3fea2d0395
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
  1. 9
      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

Loading…
Cancel
Save