feat: Banner-Check — Historie, persistentes Ergebnis, E-Mail-Report
1. localStorage Persistenz: URL, letztes Ergebnis, Historie (30 Eintraege) 2. Historie: Zeigt URL, Datum, Provider, Violations, Prozent 3. Letztes Ergebnis bleibt nach Tab-Wechsel/Reload sichtbar 4. E-Mail-Report: HTML-formatiert mit Violations + Hints an mailpit 5. Email-Status Anzeige im Frontend Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -110,9 +110,52 @@ async def run_banner_check(req: BannerCheckRequest):
|
||||
"categories": req.categories,
|
||||
},
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
return resp.json()
|
||||
return {"error": f"Consent-Tester: HTTP {resp.status_code}"}
|
||||
if resp.status_code != 200:
|
||||
return {"error": f"Consent-Tester: HTTP {resp.status_code}"}
|
||||
|
||||
result = resp.json()
|
||||
|
||||
# Send email report
|
||||
checks = result.get("structured_checks", [])
|
||||
violations = [c for c in checks if not c.get("passed") and not c.get("skipped")]
|
||||
passes = [c for c in checks if c.get("passed")]
|
||||
provider = result.get("banner_provider", "Unbekannt")
|
||||
comp_pct = result.get("completeness_pct", 0)
|
||||
|
||||
html = [
|
||||
'<div style="font-family:-apple-system,sans-serif;max-width:700px;margin:0 auto">',
|
||||
f'<h2>Banner-Check: {req.url}</h2>',
|
||||
f'<p>Banner: {provider} | Vollstaendigkeit: {comp_pct}%</p>',
|
||||
]
|
||||
if violations:
|
||||
html.append(f'<h3 style="color:#dc2626">{len(violations)} Verstoesse</h3>')
|
||||
for v in violations:
|
||||
html.append(
|
||||
f'<div style="padding:4px 0">'
|
||||
f'<span style="color:#dc2626;font-weight:bold">✗</span> '
|
||||
f'{v.get("label","")}'
|
||||
)
|
||||
if v.get("hint"):
|
||||
html.append(
|
||||
f'<div style="font-size:11px;color:#dc2626;margin:2px 0 4px 20px;'
|
||||
f'padding:4px 8px;background:#fef2f2;border-radius:4px;'
|
||||
f'border-left:3px solid #fca5a5">{v["hint"]}</div>'
|
||||
)
|
||||
html.append('</div>')
|
||||
if passes:
|
||||
html.append(f'<h3 style="color:#22c55e">{len(passes)} Bestanden</h3>')
|
||||
for p in passes:
|
||||
html.append(f'<div style="padding:2px 0;color:#6b7280">'
|
||||
f'<span style="color:#22c55e">✓</span> {p.get("label","")}</div>')
|
||||
html.append('</div>')
|
||||
|
||||
email_result = send_email(
|
||||
recipient="dsb@breakpilot.local",
|
||||
subject=f"[BANNER-CHECK] {provider} — {req.url}",
|
||||
body_html="\n".join(html),
|
||||
)
|
||||
result["email_status"] = email_result.get("status", "failed")
|
||||
return result
|
||||
except Exception as e:
|
||||
return {"error": str(e)[:200]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user