better reader for mails

This commit is contained in:
2025-06-02 10:33:26 +02:00
parent 5a9b6be79d
commit fdef0c5f66
5 changed files with 103 additions and 101 deletions

View File

@@ -20,10 +20,13 @@ def generate_mail_from_notification(notif: Notif) -> Optional[Mail]:
"""
logger.debug(f"Generating mail for notification: {notif}")
# Convert notification type to template name format (e.g., 'account_created' -> 'Account Created')
template_name = ' '.join(word.capitalize() for word in notif.notif_type.split('_'))
# Find the corresponding email template based on notif_type
template = EmailTemplate.query.filter_by(name=notif.notif_type).first()
template = EmailTemplate.query.filter_by(name=template_name).first()
if not template:
logger.warning(f"No email template found for notification type: {notif.notif_type}")
logger.warning(f"No email template found for notification type: {notif.notif_type} (template name: {template_name})")
return None
try: