CI / test (push) Successful in 6m31s
New mail whose notify decision is true now wakes the user's registered
phones: a content-free {"kind":"sync"} payload, encrypted per RFC 8291
and VAPID-signed per RFC 8292 (key generated on first start, stored
encrypted with CREDENTIAL_KEY). Bursts coalesce into one push, and a
404/410 from the push server removes the device.
/api/devices registers, updates, lists and removes endpoints, and can
send a test push; GET /api/push returns the VAPID public key. For
self-hosted push servers, PUSH_URL_REWRITE maps the public endpoint
prefix to an internal one, and PUSH_CA_CERT / PUSH_TLS_INSECURE handle
private certificates.
Sessions now slide: each use extends expiry to the full TTL (at most
one write an hour), so a phone in regular use is never signed out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
910 B
SQL
24 lines
910 B
SQL
-- UnifiedPush device registrations (server-architecture-spec.md §3.8) and
|
|
-- server-held keys.
|
|
--
|
|
-- A device row is one phone's push subscription: the distributor-issued
|
|
-- endpoint plus the Web Push keys its messages are encrypted for (RFC 8291).
|
|
-- Keys are nullable for distributors that don't do Web Push encryption.
|
|
ALTER TABLE devices
|
|
ADD COLUMN name TEXT,
|
|
ADD COLUMN p256dh TEXT,
|
|
ADD COLUMN auth TEXT,
|
|
ADD COLUMN last_push_at TIMESTAMPTZ,
|
|
ADD COLUMN last_error TEXT;
|
|
|
|
CREATE UNIQUE INDEX devices_user_id_endpoint_idx ON devices(user_id, endpoint);
|
|
|
|
-- Keys the server generates for itself (currently the VAPID signing key),
|
|
-- encrypted with CREDENTIAL_KEY like account passwords.
|
|
CREATE TABLE server_keys (
|
|
name TEXT PRIMARY KEY,
|
|
ciphertext BYTEA NOT NULL,
|
|
nonce BYTEA NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|