R9 Web Push in decePub: one subscription per persona, each with its own token and registration
Build / Build (push) Successful in 56s
Build / Build (push) Successful in 56s
Settings gets "Notifications on this device" (PushEditor): personas, alerts in four groups, policy, a test
notification, after a one-time notice of what the push service learns. Each persona ticked gets its own service
worker registration (push-worker.js at push/{slot}/), so its own endpoint and keys, subscribed with its own token
(IHttpService's *As); nothing PrivaPub stores ties two personas together and the worker never reads the payload's
token. PushService follows the tokens (re-subscribing after a renewal), reconciles at every session start, turns
off before sign-out and drops deleted or suspended personas. A click opens that persona's notifications; the app
badge counts the unread ones. Exchanges now ask for the push scope.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpVCoDeM1qUTRp4fXQdfof
This commit is contained in:
1 parent
d33697e3fc
commit
ab17959ed4
29 files changed
+2047
-67
No files matched your search
@@ -0,0 +1,55 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace decePubClient.Models.Mastodon;
|
||||
|
||||
/// <summary>Mastodon's WebPushSubscription (/api/v1/push/subscription): one per access token, so one per persona.
|
||||
/// Alerts holds every alert PrivaPub knows, true or false.</summary>
|
||||
public class WebPushSubscription
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Endpoint { get; set; }
|
||||
public bool Standard { get; set; }
|
||||
public Dictionary<string, bool> Alerts { get; set; } = [];
|
||||
/// <summary>The server's VAPID public key, URL-safe base64.</summary>
|
||||
public string ServerKey { get; set; }
|
||||
/// <summary>all, followed, follower or none.</summary>
|
||||
public string Policy { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>POST /api/v1/push/subscription as JSON: the browser's subscription and what it is pushed. PrivaPub reads it as
|
||||
/// Mastodon's flattened parameters (subscription[endpoint], subscription[keys][p256dh], data[alerts][mention], ...).</summary>
|
||||
public class PushSubscriptionForm
|
||||
{
|
||||
public PushEndpoint Subscription { get; set; } = new();
|
||||
public PushData Data { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>The browser's push subscription: where the push service takes the pushes, and the keys they are encrypted
|
||||
/// to. Standard: RFC 8291's aes128gcm (with RFC 8292's VAPID header), which every browser that pushes decrypts.</summary>
|
||||
public class PushEndpoint
|
||||
{
|
||||
public string Endpoint { get; set; }
|
||||
public PushKeys Keys { get; set; } = new();
|
||||
public bool Standard { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>The browser's P-256 public key and authentication secret, URL-safe base64.</summary>
|
||||
public class PushKeys
|
||||
{
|
||||
[JsonPropertyName("p256dh")]
|
||||
public string P256dh { get; set; }
|
||||
public string Auth { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>What a subscription is pushed: each alert on or off (one left out is off), and whose.</summary>
|
||||
public class PushData
|
||||
{
|
||||
public Dictionary<string, bool> Alerts { get; set; } = [];
|
||||
public string Policy { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>PUT /api/v1/push/subscription: data[alerts] and data[policy] replace what the subscription had.</summary>
|
||||
public class PushDataForm
|
||||
{
|
||||
public PushData Data { get; set; } = new();
|
||||
}
|
||||
Reference in new issue
Block a user