Skip to content

SubscriptionRepository

Viames Marino edited this page Feb 22, 2026 · 1 revision

Pair framework: SubscriptionRepository

Pair\Push\SubscriptionRepository manages push_subscriptions persistence.

Main operations

upsert(?int $userId, array $subscription, ?string $userAgent): void

Insert or update by endpoint.

Expected payload fields:

  • endpoint
  • keys.p256dh (or top-level p256dh)
  • keys.auth (or top-level auth)

If required fields are missing, it throws InvalidArgumentException.

listByUser(int $userId): Collection

Returns active subscriptions for user (revoked_at IS NULL).

revokeByEndpoint(string $endpoint): void

Soft-revokes endpoint (revoked_at timestamp).

deleteByEndpoint(string $endpoint): void

Hard delete by endpoint.

Notes

  • upsert() also refreshes updated_at and last_seen_at.
  • user_agent is truncated to 255 chars.
  • endpoint must be unique in table design for correct upsert behavior.

See also: PushDispatcher, WebPushSender, PairPush.js.

Clone this wiki locally