forked from retoor/devplacepy
Split the push delivery library into a provider architecture. devplacepy/push becomes a package: a PushProvider protocol with a registry, the existing Web Push implementation moved unchanged behind it, a new APNs provider, a store owning every push_registration access, and a delivery loop that groups a user's subscriptions by provider, prepares each provider's payload once and sends over a single shared client. APNs delivers over HTTP/2 with an ES256 provider token cached per credential fingerprint, so a worker signs at most one token per 45 minutes. Registrations carry a hexadecimal device token; 410 and the Unregistered class of reasons soft delete the subscription exactly like a gone Web Push endpoint. All provider configuration is edited at /admin/services/push through the same ConfigField surface every other subsystem uses, assembled from the registry so a future provider needs no edit to the service. A provider that is disabled, unconfigured or holding an unusable credential accepts no registrations and is skipped during delivery, never failing the other providers. POST /push.json accepts a registration for any active provider; a body without a provider field is a Web Push body, so existing clients are unchanged. GET /push.json keeps publicKey at the top level and adds the active providers. push_registration gains provider and token columns, ensured in init_db with a converging backfill; existing rows are never rewritten. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
30 lines
739 B
Python
30 lines
739 B
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
from devplacepy.push.delivery import notify_user
|
|
from devplacepy.push.providers.webpush import (
|
|
browser_base64,
|
|
create_notification_authorization,
|
|
create_notification_info_with_payload,
|
|
ensure_certificates,
|
|
generate_pkcs8_private_key,
|
|
generate_private_key,
|
|
generate_public_key,
|
|
hkdf,
|
|
public_key_standard_b64,
|
|
)
|
|
from devplacepy.push.store import register
|
|
|
|
__all__ = [
|
|
"browser_base64",
|
|
"create_notification_authorization",
|
|
"create_notification_info_with_payload",
|
|
"ensure_certificates",
|
|
"generate_pkcs8_private_key",
|
|
"generate_private_key",
|
|
"generate_public_key",
|
|
"hkdf",
|
|
"notify_user",
|
|
"public_key_standard_b64",
|
|
"register",
|
|
]
|