20 lines
892 B
C#
20 lines
892 B
C#
namespace ROLAC.API.Services.Notifications;
|
|
|
|
/// <summary>The three fields a browser hands over when it creates a push subscription.</summary>
|
|
public sealed record WebPushTarget(string Endpoint, string P256dh, string Auth);
|
|
|
|
/// <summary>
|
|
/// Outcome of pushing to one subscription. <see cref="IsExpired"/> is true when the push service
|
|
/// reported the subscription is gone (HTTP 404/410) so the caller can prune it.
|
|
/// </summary>
|
|
public sealed record WebPushSendResult(bool Success, bool IsExpired, string? Error);
|
|
|
|
/// <summary>
|
|
/// Thin wrapper over the WebPush library's encrypt-and-POST so that <see cref="WebPushService"/>'s
|
|
/// recipient resolution, pruning, and logging can be unit-tested without a real push service.
|
|
/// </summary>
|
|
public interface IWebPushSender
|
|
{
|
|
Task<WebPushSendResult> SendAsync(WebPushTarget target, string payloadJson, CancellationToken ct = default);
|
|
}
|