Send event creation and event update notifications in a background task

The event update notification is made unique so that repeated changes
only trigger one notificate every 30 minutes

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-10 20:31:29 +01:00
parent 8250d34597
commit 38a3ffc19f
9 changed files with 254 additions and 43 deletions

View File

@@ -0,0 +1,19 @@
defmodule Mobilizon.Events.UtilsTest do
use Mobilizon.DataCase, async: true
alias Mobilizon.Events.Utils
@now ~U[2021-11-19T18:17:00Z]
describe "calculate_notification_time" do
test "when the event begins in less than 30 minutes" do
begins_on = ~U[2021-11-19T18:27:00Z]
assert @now == Utils.calculate_notification_time(begins_on, now: @now)
end
test "when the event begins in more than 30 minutes" do
begins_on = ~U[2021-11-19T18:17:00Z]
assert begins_on == Utils.calculate_notification_time(begins_on, now: @now)
end
end
end