Files
coder/coderd/database/migrations/000312_webpush_subscriptions.up.sql
Cian Johnston 06e5d9ef21 feat(coderd): add webpush package (#17091)
* Adds `codersdk.ExperimentWebPush` (`web-push`)
* Adds a `coderd/webpush` package that allows sending native push
notifications via `github.com/SherClockHolmes/webpush-go`
* Adds database tables to store push notification subscriptions.
* Adds an API endpoint that allows users to subscribe/unsubscribe, and
send a test notification (404 without experiment, excluded from API docs)
* Adds server CLI command to regenerate VAPID keys (note: regenerating
the VAPID keypair requires deleting all existing subscriptions)

---------

Co-authored-by: Kyle Carberry <kyle@carberry.com>
2025-03-27 10:03:53 +00:00

14 lines
701 B
SQL

-- webpush_subscriptions is a table that stores push notification
-- subscriptions for users. These are acquired via the Push API in the browser.
CREATE TABLE IF NOT EXISTS webpush_subscriptions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users ON DELETE CASCADE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
-- endpoint is called by coderd to send a push notification to the user.
endpoint TEXT NOT NULL,
-- endpoint_p256dh_key is the public key for the endpoint.
endpoint_p256dh_key TEXT NOT NULL,
-- endpoint_auth_key is the authentication key for the endpoint.
endpoint_auth_key TEXT NOT NULL
);