using decePubClient.Models.Types; namespace decePubClient.Models { /// /// Web Push on this device (Services/PushService.cs), kept in localStorage under its type name: the personas whose /// notifications reach it, and the alerts and policy each of their subscriptions holds. Never a token: each persona's /// subscription is made with that persona's own token, which only AuthData keeps. /// public class PushDevice { /// The personas subscribed on this device, each through its own service worker registration. public List Personas { get; set; } = []; /// The alerts turned on (PushAlerts.Offered's names). public List Alerts { get; set; } = [.. PushAlerts.Offered]; public PushPolicy Policy { get; set; } = PushPolicy.All; } /// One persona's subscription on this device. public class PushPersona { /// The persona's avatar id. public string PersonaId { get; set; } /// A random name this device gives the persona's service worker registration (its scope is push/{slot}/), so /// the persona's subscription has an endpoint and keys of its own; it means nothing anywhere else. public string Slot { get; set; } /// PrivaPub's id for the subscription, as it last answered. public string SubscriptionId { get; set; } } /// What js/push.js says of this browser: whether it can be pushed to, why not (insecure, unsupported, or /// ios-install: an iPhone or iPad pushes only to the app added to the Home Screen), and what the reader allowed. public class PushSupport { public bool Supported { get; set; } public string Reason { get; set; } /// default, granted or denied (Notification.permission). public string Permission { get; set; } public bool IsGranted => Permission == "granted"; public bool IsDenied => Permission == "denied"; } /// A persona's push subscription in this browser, as js/push.js reads it (its keys URL-safe base64), or why it /// couldn't be made. public class BrowserSubscription { public string Endpoint { get; set; } public string P256dh { get; set; } public string Auth { get; set; } public bool Standard { get; set; } public string Error { get; set; } } }