Dateien
AegisSight-Monitor/src/email_utils/templates.py
claude-dev 71296edb97 Großes Cleanup: Bugs fixen, Features fertigstellen, toten Code entfernen
Bugs behoben:
- handleEdit() async keyword hinzugefügt (E-Mail-Checkboxen funktionieren jetzt)
- parseUTC() Funktion definiert (Fortschritts-Timer nutzt Server-Startzeit)
- Status cancelling wird im Frontend korrekt angezeigt

Features fertiggestellt:
- Sidebar: Lagen nach Typ getrennt (adhoc/research) mit Zählern
- Quellen-Bearbeiten: Edit-Button pro Quelle, Formular vorausfüllen
- Lizenz-Info: Org-Name und Lizenzstatus im Header angezeigt

Toter Code entfernt:
- 5 verwaiste Dateien gelöscht (alte rss_parser, style.css, components.js, layout.js, setup_users)
- 6 ungenutzte Pydantic Models entfernt
- Ungenutzte Funktionen/Imports in auth.py, routers, agents, config
- Tote API-Methoden, Legacy-UI-Methoden, verwaiste WS-Handler
- Abgeschlossene DB-Migrationen aufgeräumt

Sonstiges:
- requirements.txt: passlib[bcrypt] durch bcrypt ersetzt
- Umlaute korrigiert (index.html)
- CSS: incident-type-label → incident-type-badge, .login-success hinzugefügt
- Schließen statt Schliessen im Feedback-Modal
2026-03-04 18:45:38 +01:00

104 Zeilen
4.3 KiB
Python

"""HTML-E-Mail-Vorlagen fuer Magic Links, Einladungen und Benachrichtigungen."""
def magic_link_login_email(username: str, code: str, link: str) -> tuple[str, str]:
"""Erzeugt Login-E-Mail mit Magic Link und Code.
Returns:
(subject, html_body)
"""
subject = f"AegisSight Monitor - Anmeldung"
html = f"""<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f172a; color: #e2e8f0; padding: 40px 20px;">
<div style="max-width: 480px; margin: 0 auto; background: #1e293b; border-radius: 12px; padding: 32px; border: 1px solid #334155;">
<h1 style="color: #f0b429; font-size: 20px; margin: 0 0 24px 0;">AegisSight Monitor</h1>
<p style="margin: 0 0 16px 0;">Hallo {username},</p>
<p style="margin: 0 0 24px 0;">Klicken Sie auf den Link oder geben Sie den Code ein, um sich anzumelden:</p>
<div style="background: #0f172a; border-radius: 8px; padding: 20px; text-align: center; margin: 0 0 24px 0;">
<div style="font-size: 32px; font-weight: 700; letter-spacing: 8px; color: #f0b429; font-family: monospace;">{code}</div>
</div>
<div style="text-align: center; margin: 0 0 24px 0;">
<a href="{link}" style="display: inline-block; background: #f0b429; color: #0f172a; padding: 12px 32px; border-radius: 6px; text-decoration: none; font-weight: 600;">Jetzt anmelden</a>
</div>
<p style="color: #94a3b8; font-size: 13px; margin: 0;">Dieser Link ist 10 Minuten gueltig. Falls Sie diese Anmeldung nicht angefordert haben, ignorieren Sie diese E-Mail.</p>
</div>
</body>
</html>"""
return subject, html
def incident_notification_email(
username: str,
incident_title: str,
notifications: list[dict],
dashboard_url: str,
) -> tuple[str, str]:
"""Erzeugt Benachrichtigungs-E-Mail fuer Lagen-Updates.
Args:
username: Empfaenger-Name
incident_title: Titel der Lage/Recherche
notifications: Liste von {"text": ..., "icon": ...} Dicts
dashboard_url: Link zum Dashboard
Returns:
(subject, html_body)
"""
subject = f"AegisSight - {incident_title}"
icon_map = {
"success": "&#10003;", # Haekchen
"warning": "&#9888;", # Warndreieck
"error": "&#10007;", # Kreuz
"info": "&#9432;", # Info-Kreis
}
color_map = {
"success": "#22c55e",
"warning": "#f0b429",
"error": "#ef4444",
"info": "#94a3b8",
}
items_html = ""
for n in notifications:
icon = icon_map.get(n.get("icon", "info"), "&#9432;")
color = color_map.get(n.get("icon", "info"), "#94a3b8")
text = n.get("text", "")
items_html += f"""
<div style="display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid #334155;">
<span style="color: {color}; font-size: 18px; line-height: 1;">{icon}</span>
<span style="color: #e2e8f0; font-size: 14px; line-height: 1.4;">{text}</span>
</div>"""
html = f"""<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f172a; color: #e2e8f0; padding: 40px 20px;">
<div style="max-width: 480px; margin: 0 auto; background: #1e293b; border-radius: 12px; padding: 32px; border: 1px solid #334155;">
<h1 style="color: #f0b429; font-size: 20px; margin: 0 0 8px 0;">AegisSight Monitor</h1>
<p style="color: #94a3b8; font-size: 12px; margin: 0 0 24px 0;">Lagebericht-Benachrichtigung</p>
<p style="margin: 0 0 8px 0;">Hallo {username},</p>
<p style="margin: 0 0 20px 0;">es gibt Neuigkeiten zur Lage <strong style="color: #f0b429;">{incident_title}</strong>:</p>
<div style="background: #0f172a; border-radius: 8px; padding: 4px 16px; margin: 0 0 24px 0;">
{items_html}
</div>
<div style="text-align: center; margin: 0 0 24px 0;">
<a href="{dashboard_url}" style="display: inline-block; background: #f0b429; color: #0f172a; padding: 12px 32px; border-radius: 6px; text-decoration: none; font-weight: 600;">Im Dashboard ansehen</a>
</div>
<p style="color: #64748b; font-size: 12px; margin: 0;">Diese Benachrichtigung kann in den Einstellungen im Dashboard deaktiviert werden.</p>
</div>
</body>
</html>"""
return subject, html