"""HTML-E-Mail-Vorlagen für Magic Links, Einladungen und Benachrichtigungen.
Sprache pro Empfaenger-Org gesteuert (Default 'de').
"""
def magic_link_login_email(username: str, link: str, lang: str = "de") -> tuple[str, str]:
"""Erzeugt Login-E-Mail mit Magic Link.
Args:
username: Empfaenger-Anzeigename
link: Magic-Link-URL
lang: ISO-Sprachcode ('de' | 'en')
Returns:
(subject, html_body)
"""
if lang == "en":
subject = "AegisSight Monitor - Sign in"
body = (
"Hi {username},",
"Click the button below to sign in:",
"Sign in",
"Or copy this link into your browser:",
"This link is valid for 10 minutes. If you did not request this sign-in, simply ignore this email.",
)
else:
subject = "AegisSight Monitor - Anmeldung"
body = (
"Hallo {username},",
"Klicken Sie auf den Button, um sich anzumelden:",
"Jetzt anmelden",
"Oder kopieren Sie diesen Link in Ihren Browser:",
"Dieser Link ist 10 Minuten gültig. Falls Sie diese Anmeldung nicht angefordert haben, ignorieren Sie diese E-Mail.",
)
greeting, intro, button_label, copy_hint, validity = body
html = f"""
AegisSight Monitor
{greeting.format(username=username)}
{intro}
{copy_hint}
{link}
{validity}
"""
return subject, html
def incident_notification_email(
username: str,
incident_title: str,
notifications: list[dict],
dashboard_url: str,
incident_type: str = "adhoc",
lang: str = "de",
) -> tuple[str, str]:
"""Erzeugt Benachrichtigungs-E-Mail für Lagen-Updates.
Args:
username: Empfaenger-Name
incident_title: Titel der Lage/Recherche
notifications: Liste von {"text": ..., "icon": ...} Dicts
dashboard_url: Link zum Dashboard
incident_type: "adhoc" oder "research"
lang: ISO-Sprachcode ('de' | 'en')
Returns:
(subject, html_body)
"""
is_research = incident_type == "research"
if lang == "en":
type_label = "Research" if is_research else "Situation"
type_label_lower = "research" if is_research else "situation"
notification_word = "notification"
greeting = f"Hi {username},"
intro = f"There is news on the {type_label_lower}"
button_label = "Open in dashboard"
footer = "You can disable these notifications in your dashboard settings."
else:
type_label = "Recherche" if is_research else "Lagebild"
type_label_lower = "Recherche" if is_research else "Lage"
notification_word = "Benachrichtigung"
greeting = f"Hallo {username},"
intro = f"es gibt Neuigkeiten zur {type_label_lower}"
button_label = "Im Dashboard ansehen"
footer = "Diese Benachrichtigung kann in den Einstellungen im Dashboard deaktiviert werden."
subject = f"AegisSight - {incident_title}"
icon_map = {
"success": "✓",
"warning": "⚠",
"error": "✗",
"info": "ⓘ",
}
color_map = {
"success": "#22c55e",
"warning": "#f0b429",
"error": "#ef4444",
"info": "#94a3b8",
}
items_html = ""
for n in notifications:
icon = icon_map.get(n.get("icon", "info"), "ⓘ")
color = color_map.get(n.get("icon", "info"), "#94a3b8")
text = n.get("text", "")
items_html += f"""
{icon}
{text}
"""
html = f"""
AegisSight Monitor
{type_label} - {notification_word}
{greeting}
{intro} {incident_title}:
{items_html}
{footer}
"""
return subject, html