Add customizable email templates and remove alert recipients
All checks were successful
PostgreSQL Compatibility Matrix / PG14 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG15 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG16 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG17 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG18 smoke (push) Successful in 7s
All checks were successful
PostgreSQL Compatibility Matrix / PG14 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG15 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG16 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG17 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG18 smoke (push) Successful in 7s
Replaced the fixed `alert_recipients` list with customizable subject and body templates for alerts and warnings. This allows for more flexible and dynamic email notifications using placeholder variables. Updated relevant backend and frontend components to support this feature.
This commit is contained in:
@@ -29,7 +29,6 @@ async def _get_or_create_settings(db: AsyncSession) -> EmailNotificationSettings
|
||||
|
||||
|
||||
def _to_out(settings: EmailNotificationSettings) -> EmailSettingsOut:
|
||||
recipients = settings.alert_recipients if isinstance(settings.alert_recipients, list) else []
|
||||
return EmailSettingsOut(
|
||||
enabled=settings.enabled,
|
||||
smtp_host=settings.smtp_host,
|
||||
@@ -39,7 +38,10 @@ def _to_out(settings: EmailNotificationSettings) -> EmailSettingsOut:
|
||||
from_email=settings.from_email,
|
||||
use_starttls=settings.use_starttls,
|
||||
use_ssl=settings.use_ssl,
|
||||
alert_recipients=recipients,
|
||||
warning_subject_template=settings.warning_subject_template,
|
||||
alert_subject_template=settings.alert_subject_template,
|
||||
warning_body_template=settings.warning_body_template,
|
||||
alert_body_template=settings.alert_body_template,
|
||||
has_password=bool(settings.encrypted_smtp_password),
|
||||
updated_at=settings.updated_at,
|
||||
)
|
||||
@@ -70,7 +72,10 @@ async def update_email_settings(
|
||||
settings.from_email = str(payload.from_email) if payload.from_email else None
|
||||
settings.use_starttls = payload.use_starttls
|
||||
settings.use_ssl = payload.use_ssl
|
||||
settings.alert_recipients = [str(item) for item in payload.alert_recipients]
|
||||
settings.warning_subject_template = payload.warning_subject_template.strip() if payload.warning_subject_template else None
|
||||
settings.alert_subject_template = payload.alert_subject_template.strip() if payload.alert_subject_template else None
|
||||
settings.warning_body_template = payload.warning_body_template.strip() if payload.warning_body_template else None
|
||||
settings.alert_body_template = payload.alert_body_template.strip() if payload.alert_body_template else None
|
||||
|
||||
if payload.clear_smtp_password:
|
||||
settings.encrypted_smtp_password = None
|
||||
|
||||
Reference in New Issue
Block a user