Roadmap 'Webhook events': per-license outbound webhooks with HMAC-SHA256 signatures (X-Corrosion-Signature), 5s timeout, fire-and-forget (a webhook failure never breaks the triggering action), last_delivery_at/last_status tracked. - migration 024_webhooks; Webhook entity (events as simple-array); WebhooksModule (@Global, exports WebhooksService) wired into app.module; CRUD controller (license-scoped, webhooks.view/manage). - Hooked events: players.performAction ban -> 'player_banned'; host-agent-consumer going-offline + staleness sweep -> 'server_down'. - 'wipe_completed' event lands next (needs wipe status from the agent reply). Backend tsc green. Migration applies on a fresh DB (Saturday). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
27 lines
1.2 KiB
SQL
27 lines
1.2 KiB
SQL
-- 024_webhooks.sql
|
|
-- Per-license outbound webhook registry.
|
|
-- Operators register URLs + event subscriptions; the backend POSTs signed
|
|
-- JSON payloads on matching events (player_banned, server_down, …).
|
|
|
|
CREATE TABLE webhooks (
|
|
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
license_id uuid NOT NULL REFERENCES licenses(id) ON DELETE CASCADE,
|
|
name varchar(100) NOT NULL,
|
|
url text NOT NULL,
|
|
-- Comma-separated event keys, e.g. 'player_banned,server_down'
|
|
-- TypeORM simple-array maps this transparently to string[].
|
|
events text NOT NULL,
|
|
-- HMAC-SHA256 signing secret; generated server-side if omitted on create.
|
|
secret varchar(128) NOT NULL,
|
|
is_active boolean NOT NULL DEFAULT true,
|
|
-- Populated after each delivery attempt.
|
|
last_delivery_at timestamptz NULL,
|
|
-- 'ok' | 'failed' — last HTTP delivery outcome.
|
|
last_status varchar(20) NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
|
|
CONSTRAINT webhooks_pkey PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE INDEX idx_webhooks_license_id ON webhooks (license_id);
|