feat(email): send booking reminders before event start.

Job process_reminders in subscription_worker; REMINDER_LEAD_HOURS window;
CalenTIQ email + in-app event_reminder; idempotent reminder_sent.
Refs EventHub/EventHubBack#70
This commit is contained in:
2026-08-14 20:59:38 +03:00
parent 347a645933
commit 15ae8d4426
9 changed files with 245 additions and 6 deletions
+22 -1
View File
@@ -7,7 +7,8 @@ logic_email_test_() ->
{"mock deliver gets CalenTIQ + verify url", fun test_verify_deliver/0},
{"invite and reset urls", fun test_invite_reset/0},
{"deliver error still ok", fun test_deliver_error/0},
{"html template placeholders filled", fun test_template_fill/0}
{"html template placeholders filled", fun test_template_fill/0},
{"booking reminder deliver", fun test_reminder_deliver/0}
]}.
setup() ->
@@ -81,3 +82,23 @@ test_template_fill() ->
?assert(binary:match(Plain, <<"https://x/verify?token=z">>) =/= nomatch),
?assert(binary:match(Html, <<"{{">>) =:= nomatch),
?assert(binary:match(Html, <<"https://x/verify?token=z">>) =/= nomatch).
test_reminder_deliver() ->
Self = self(),
application:set_env(eventhub, smtp_host, "smtp.test"),
application:set_env(eventhub, smtp_deliver,
fun(_From, To, Raw, _Opts) ->
Self ! {smtp, To, Raw},
{ok, mock}
end),
Start = {{2026, 8, 15}, {10, 30, 0}},
?assertEqual(ok, logic_email:send_booking_reminder(
<<"u@ex.com">>, <<"Yoga hour">>, Start, <<"/c/cal1/e/ev1">>)),
receive
{smtp, <<"u@ex.com">>, Raw} ->
?assert(binary:match(Raw, <<"/c/cal1/e/ev1">>) =/= nomatch),
?assert(binary:match(Raw, <<"Yoga hour">>) =/= nomatch),
?assert(binary:match(Raw, <<"2026-08-15 10:30">>) =/= nomatch)
after 1000 ->
error(timeout)
end.