Chatto.Api.V1.PushNotificationService (chatto v0.1.0)

Copy Markdown View Source

Browser Web Push subscription commands for the authenticated user.

Summary

Functions

Sends a test notification to the caller's registered browser subscriptions. Calls are rate-limited per account. Delivery failures return a generic unavailable error without exposing the push provider's response body.

Stores or updates the caller's browser push subscription.

Removes the caller's browser push subscription by endpoint.

Functions

send_test_notification(client, request)

@spec send_test_notification(
  Req.Request.t(),
  Chatto.Api.V1.SendTestNotificationRequest.t()
) ::
  {:ok, Chatto.Api.V1.SendTestNotificationResponse.t()}
  | {:error, Chatto.Connect.Error.t()}

Sends a test notification to the caller's registered browser subscriptions. Calls are rate-limited per account. Delivery failures return a generic unavailable error without exposing the push provider's response body.

subscribe(client, request)

@spec subscribe(Req.Request.t(), Chatto.Api.V1.SubscribeRequest.t()) ::
  {:ok, Chatto.Api.V1.SubscribeResponse.t()}
  | {:error, Chatto.Connect.Error.t()}

Stores or updates the caller's browser push subscription.

The server must have Web Push configured. Clients normally call this after the browser grants notification permission and returns a PushSubscription. A stored subscription expires 180 days after its most recent save. The client owns the refresh: call Subscribe again when the app starts and at least once a day while it runs, and when the browser replaces the PushSubscription. The server removes expired records itself. Call Unsubscribe to stop delivery before the subscription expires.

unsubscribe(client, request)

@spec unsubscribe(Req.Request.t(), Chatto.Api.V1.UnsubscribeRequest.t()) ::
  {:ok, Chatto.Api.V1.UnsubscribeResponse.t()}
  | {:error, Chatto.Connect.Error.t()}

Removes the caller's browser push subscription by endpoint.

The call is idempotent: removing an unknown endpoint still succeeds.