using ROLAC.API.Entities;

namespace ROLAC.API.Entities.Notifications;

/// <summary>
/// A browser/device Web Push subscription owned by a member. Unlike <see cref="MemberChannelBinding"/>
/// (one external id per channel), web push needs the endpoint URL plus two keys, and a member can
/// have several — one per device/browser they enable notifications on. Targeting a member resolves
/// all of their subscriptions.
/// </summary>
public class WebPushSubscription
{
    public int      Id         { get; set; }
    public int      MemberId   { get; set; }
    public Member?  Member     { get; set; }

    /// <summary>The push service endpoint URL (unique per subscription).</summary>
    public string   Endpoint   { get; set; } = null!;

    /// <summary>The subscription's P-256 ECDH public key (base64url).</summary>
    public string   P256dh     { get; set; } = null!;

    /// <summary>The subscription's auth secret (base64url).</summary>
    public string   Auth       { get; set; } = null!;

    /// <summary>The originating user agent, kept for display/debugging.</summary>
    public string?  UserAgent  { get; set; }

    public DateTime CreatedAt  { get; set; }

    /// <summary>Last time a push to this subscription succeeded.</summary>
    public DateTime? LastUsedAt { get; set; }
}
