generated from bisco/codex-bootstrap
fix(dev): log confirmation links locally
This commit is contained in:
@@ -13,6 +13,18 @@ def build_confirmation_link(raw_confirmation_token):
|
||||
return f"{settings.SITE_BASE_URL}{CONFIRMATION_PATH}?token={raw_confirmation_token}"
|
||||
|
||||
|
||||
def _log_confirmation_link_for_local_debug(*, reservation, confirmation_link, reason):
|
||||
if not settings.LOG_RESERVATION_CONFIRMATION_URLS:
|
||||
return
|
||||
|
||||
logger.info(
|
||||
"Local reservation confirmation link for manual testing (%s) for reservation %s: %s",
|
||||
reason,
|
||||
reservation.id,
|
||||
confirmation_link,
|
||||
)
|
||||
|
||||
|
||||
def send_confirmation_email(*, reservation, raw_confirmation_token):
|
||||
confirmation_link = build_confirmation_link(raw_confirmation_token)
|
||||
subject = f"Confirm your reservation for {reservation.performance.show.title}"
|
||||
@@ -23,6 +35,12 @@ def send_confirmation_email(*, reservation, raw_confirmation_token):
|
||||
"If you did not request this reservation, you can ignore this email."
|
||||
)
|
||||
|
||||
_log_confirmation_link_for_local_debug(
|
||||
reservation=reservation,
|
||||
confirmation_link=confirmation_link,
|
||||
reason="email send attempt",
|
||||
)
|
||||
|
||||
try:
|
||||
send_mail(
|
||||
subject=subject,
|
||||
@@ -32,6 +50,11 @@ def send_confirmation_email(*, reservation, raw_confirmation_token):
|
||||
fail_silently=False,
|
||||
)
|
||||
except Exception:
|
||||
_log_confirmation_link_for_local_debug(
|
||||
reservation=reservation,
|
||||
confirmation_link=confirmation_link,
|
||||
reason="email send failure fallback",
|
||||
)
|
||||
logger.exception(
|
||||
"Failed to send confirmation email for reservation %s.",
|
||||
reservation.id,
|
||||
|
||||
Reference in New Issue
Block a user