feat(statuspages): email subscriptions, RSS feed and a JSON API
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Successful in 9m5s
ci / lint (pull_request) Successful in 10m24s
ci / build (pull_request) Successful in 18m10s
ci / image (pull_request) Successful in 5m16s

Visitors can subscribe to a page's incidents by email where the
organization allows it. They confirm their address first; confirmation
and unsubscribe links only show a button, so mail scanners do not act on
them, and mails carry RFC 8058 one-click unsubscribe headers. Subscribers
get a mail when an incident opens or resolves and for every public
update.

Every page also has an RSS feed of incidents and planned maintenance and
a read-only JSON API (status, summary, components, incidents), both
served from the cached snapshot.

Abuse protection: status page servers limit feed and API reads,
subscription requests and link actions per visitor; the API limits
subscription requests per visitor, mailbox and page, and a new limit caps
the subscriptions an organization's pages gain in seven days (platform
default and per-organization override, 1000 in the cloud). Unconfirmed
subscriptions count towards it and are deleted after a week.

The fixed cap of 200 monitors per status page is gone; the configurable
limit alone decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-26 18:18:08 +01:00
1 parent df39b765cb
commit cca4e80e54
39 files changed
+4332 -1408

No files matched your search

@@ -0,0 +1,68 @@
-- +goose Up
-- Visitors of a status page can subscribe to its incidents by email once
-- the organization allows it on the page.
ALTER TABLE status_pages ADD COLUMN subscriptions boolean NOT NULL DEFAULT false;
-- How many subscriptions the pages of the organization may gain in seven
-- days; NULL follows the platform default, 0 means unlimited.
ALTER TABLE orgs ADD COLUMN limit_subscribers_per_week integer CHECK (limit_subscribers_per_week >= 0);
CREATE TABLE status_page_subscribers (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
org_id uuid NOT NULL,
page_id uuid NOT NULL,
email citext NOT NULL CHECK (length(email) BETWEEN 3 AND 254),
-- Language of the mails, as the visitor's browser asked for it.
locale text NOT NULL DEFAULT 'en',
-- Where the subscriber saw the page, for the links in mails when the
-- platform does not know where the page is served.
page_url text NOT NULL DEFAULT '',
created_at timestamptz NOT NULL DEFAULT now(),
-- Set once the address confirmed the subscription; until then nothing
-- is sent to it but the confirmation.
confirmed_at timestamptz,
UNIQUE (page_id, email),
FOREIGN KEY (page_id, org_id) REFERENCES status_pages (id, org_id) ON DELETE CASCADE
);
-- Counts the subscriptions of the last days for the weekly limit.
CREATE INDEX status_page_subscribers_org_idx ON status_page_subscribers (org_id, created_at);
-- Outbox: a row per subscriber and incident event.
CREATE TABLE subscriber_notifications (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
org_id uuid NOT NULL REFERENCES orgs (id) ON DELETE CASCADE,
subscriber_id uuid NOT NULL REFERENCES status_page_subscribers (id) ON DELETE CASCADE,
incident_id uuid NOT NULL REFERENCES incidents (id) ON DELETE CASCADE,
-- The public update announced, for event 'update'.
update_id uuid REFERENCES incident_updates (id) ON DELETE CASCADE,
event text NOT NULL CHECK (event IN ('opened', 'resolved', 'update')),
status text NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'sent', 'failed')),
attempts integer NOT NULL DEFAULT 0,
next_attempt_at timestamptz NOT NULL DEFAULT now(),
last_error text,
created_at timestamptz NOT NULL DEFAULT now(),
sent_at timestamptz
);
CREATE UNIQUE INDEX subscriber_notifications_once_idx
ON subscriber_notifications (subscriber_id, incident_id, event, coalesce(update_id, '00000000-0000-0000-0000-000000000000'));
CREATE INDEX subscriber_notifications_due_idx ON subscriber_notifications (next_attempt_at) WHERE status = 'pending';
ALTER TABLE status_page_subscribers ENABLE ROW LEVEL SECURITY;
ALTER TABLE status_page_subscribers FORCE ROW LEVEL SECURITY;
CREATE POLICY status_page_subscribers_tenant ON status_page_subscribers FOR ALL
USING (app_scope_system() OR org_id = app_org_id())
WITH CHECK (app_scope_system() OR org_id = app_org_id());
ALTER TABLE subscriber_notifications ENABLE ROW LEVEL SECURITY;
ALTER TABLE subscriber_notifications FORCE ROW LEVEL SECURITY;
CREATE POLICY subscriber_notifications_tenant ON subscriber_notifications FOR ALL
USING (app_scope_system() OR org_id = app_org_id())
WITH CHECK (app_scope_system() OR org_id = app_org_id());
-- +goose Down
DROP TABLE subscriber_notifications;
DROP TABLE status_page_subscribers;
ALTER TABLE orgs DROP COLUMN limit_subscribers_per_week;
ALTER TABLE status_pages DROP COLUMN subscriptions;