package de.oaa.xxx.mail; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; /** * Generates HTML email bodies with inline styles derived from app.theme.* properties. * Changing theme colors in application.properties automatically updates email appearance. * (Email clients don't support external CSS or CSS variables, so styles must be inlined.) */ @Service public class MailTemplateService { @Value("${app.theme.color-bg:#1a1a2e}") private String colorBg; @Value("${app.theme.color-card:#16213e}") private String colorCard; @Value("${app.theme.color-primary:#e94560}") private String colorPrimary; @Value("${app.theme.color-secondary:#0f3460}") private String colorSecondary; @Value("${app.theme.color-text:#eeeeee}") private String colorText; @Value("${app.theme.color-muted:#888888}") private String colorMuted; @Value("${app.theme.color-success:#2ecc71}") private String colorSuccess; public String buildEmailChangeMail(String name, String confirmLink, String newEmail) { return """

XXX The Game

Moin %s,

Du hast eine Änderung deiner E-Mail-Adresse angefordert.

Klick auf den Button, um deine neue Adresse %s zu bestätigen:

E-Mail-Adresse bestätigen

Falls du diese Änderung nicht angefordert hast, kannst du diese E-Mail einfach ignorieren.

""".formatted( colorBg, colorText, colorCard, colorSecondary, colorPrimary, colorText, name, colorText, colorText, colorPrimary, newEmail, confirmLink, colorPrimary, colorSecondary, colorMuted ); } public String buildPasswordResetMail(String name, String resetLink) { return """

XXX The Game

Moin %s,

Du hast eine Anfrage zum Zurücksetzen deines Passworts gestellt.

Klick auf den Button, um ein neues Passwort zu vergeben:

Passwort zurücksetzen

Falls du diese Anfrage nicht gestellt hast, kannst du diese E-Mail einfach ignorieren.

""".formatted( colorBg, colorText, colorCard, colorSecondary, colorPrimary, colorText, name, colorText, colorText, resetLink, colorPrimary, colorSecondary, colorMuted ); } public String buildKeyholderInvitationMail(String keyholderName, String lockeeName, String lockName, String confirmLink) { return """

XXX The Game

Moin %s,

%s hat dich als Keyholder*In für das Chastity-Lock %s eingetragen.

Wenn du die Keyholder*In-Rolle annehmen möchtest, klicke auf den Button. Das Lock startet erst nach deiner Bestätigung mit dir als Keyholder*In.

Keyholder*In-Rolle annehmen

Falls du die Rolle nicht annehmen möchtest, kannst du diese E-Mail einfach ignorieren. Das Lock läuft dann als Self-Lock weiter.

""".formatted( colorBg, colorText, colorCard, colorSecondary, colorPrimary, colorText, keyholderName, colorText, colorPrimary, lockeeName, colorPrimary, lockName, colorText, confirmLink, colorPrimary, colorSecondary, colorMuted ); } public String buildNotificationMail(String name, String text, String targetUrl, String baseUrl) { String actionButton = targetUrl != null ? """
Zur Anwendung
""".formatted(baseUrl, targetUrl, colorPrimary) : "
"; String settingsUrl = baseUrl + "/konto/einstellungen.html#sec-benachrichtigungen"; return """

XXX The Game

Hallo %s,

%s

%s

Du erhältst diese E-Mail, weil du E-Mail-Benachrichtigungen für diese Kategorie aktiviert hast. Du kannst deine Einstellungen jederzeit unter Einstellungen → Benachrichtigungen anpassen.

""".formatted( colorBg, colorText, colorCard, colorSecondary, colorPrimary, colorText, name, colorText, text, actionButton, colorSecondary, colorMuted, settingsUrl, colorPrimary ); } public String buildActivationMail(String name, String activationLink, String activatePageUrl, String uuid) { return """

XXX The Game

Moin %s,

Vielen Dank für deine Anmeldung!

Klick auf den Button, um deine E-Mail-Adresse zu bestätigen:

E-Mail bestätigen

Falls der Button nicht funktioniert, öffne %s und gib folgenden Code ein:

%s

Viel Spaß beim Spiel!

""".formatted( colorBg, colorText, colorCard, colorSecondary, colorPrimary, colorText, name, colorText, colorText, activationLink, colorPrimary, colorSecondary, colorMuted, activatePageUrl, colorPrimary, activatePageUrl, colorSecondary, colorText, uuid, colorMuted ); } }