fix: preserve request actions and soften test-mode mail failures

This commit is contained in:
Md Bayazid Bostame
2026-03-30 12:41:40 +02:00
parent ca9e890b0b
commit bce58b3f25
3 changed files with 46 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
from datetime import timedelta
from pathlib import Path
import logging
from django.conf import settings
from django.utils import timezone
@@ -11,6 +12,8 @@ from .forms import OnboardingRequestForm
from .models import NotificationRule, NotificationTemplate, OnboardingRequest, ScheduledWelcomeEmail, WorkflowConfig
from .services import get_email_test_redirect, is_email_test_mode
logger = logging.getLogger(__name__)
def resolve_workflow_emails() -> tuple[str, str, str, str, str]:
config = WorkflowConfig.objects.order_by('id').first()
@@ -42,13 +45,19 @@ def send_workflow_email(
f"Originale Empfänger: {', '.join(recipients)}\n\n{body}"
)
send_system_email(
subject=subject,
body=effective_body,
to=effective_to,
attachments=[str(a) for a in (attachments or [])],
from_email=from_email,
)
try:
send_system_email(
subject=subject,
body=effective_body,
to=effective_to,
attachments=[str(a) for a in (attachments or [])],
from_email=from_email,
)
except OSError as exc:
if is_email_test_mode():
logger.warning('Email send skipped in test mode because SMTP is unavailable: %s', exc)
return
raise
def render_notification_template(template_key: str, context: dict, language_code: str | None = None) -> tuple[str, str]: