using ROLAC.API.Entities.Base;
namespace ROLAC.API.Entities;

/// <summary>
/// Singleton (Id == 1) holding the editable SMTP + Line notification settings. This row — not the
/// "Smtp"/"Line" appsettings sections — is the runtime source of truth; those sections only seed
/// this row once on first startup. Read at send time via <c>INotificationSettingsService</c> so
/// edits apply without restarting the API.
///
/// Secrets (<see cref="SmtpPassword"/>, <see cref="LineChannelAccessToken"/>,
/// <see cref="LineChannelSecret"/>) are stored plaintext and protected by RBAC (the <c>Settings</c>
/// module / super_admin) per the project decision for this small single-VM internal app.
/// </summary>
public class NotificationSetting : AuditableEntity, IAuditable
{
    public int    Id          { get; set; }

    // ── Email (SMTP) ─────────────────────────────────────────────────────────
    public bool   EnableEmail { get; set; }
    public string SmtpHost    { get; set; } = "";
    public int    SmtpPort    { get; set; } = 587;
    public bool   SmtpUseSsl  { get; set; } = true;   // true → STARTTLS
    public string SmtpUser    { get; set; } = "";
    public string SmtpPassword { get; set; } = "";
    public string FromAddress { get; set; } = "";
    public string FromName    { get; set; } = "";

    // ── Line ─────────────────────────────────────────────────────────────────
    public bool   EnableLine             { get; set; }
    public string LineChannelAccessToken { get; set; } = "";
    public string LineChannelSecret      { get; set; } = "";

    // ── Web Push (PWA browser notifications) ───────────────────────────────────
    // VAPID keys identify this server to the push services. The pair is generated once on first
    // startup if empty; the public key is safe to hand to the browser, the private key is a secret.
    public bool   EnableWebPush   { get; set; }
    public string VapidPublicKey  { get; set; } = "";
    public string VapidPrivateKey { get; set; } = "";
    public string VapidSubject    { get; set; } = "";   // "mailto:..." or the site URL
}
