tirbofish/kitgit · commit
a0dfd688a14714472114234724f685bd104b115d
feat: add repository webhooks with delivery status
Type: SSH
SSH Key Fingerprint:
Verified
SgQHY4vUORbJC3ZtdixCl62ek/4QGh/iG2FRSyjfGPc
@@ -0,0 +1,27 @@ +-- Repository webhooks + delivery log + +CREATE TABLE webhooks ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + repo_id UUID NOT NULL REFERENCES repositories(id) ON DELETE CASCADE, + url TEXT NOT NULL, + secret TEXT NOT NULL DEFAULT '', + events TEXT[] NOT NULL DEFAULT '{}', + active BOOLEAN NOT NULL DEFAULT TRUE, + created_at TIMESTAMPTZ NOT NULL DEFAULT now(), + CONSTRAINT webhooks_url_http CHECK (url ~* '^https?://') +); +CREATE INDEX webhooks_repo_id_idx ON webhooks(repo_id); + +CREATE TABLE webhook_deliveries ( + id BIGSERIAL PRIMARY KEY, + webhook_id UUID NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE, + event TEXT NOT NULL, + action TEXT NOT NULL DEFAULT '', + success BOOLEAN NOT NULL DEFAULT FALSE, + status_code INT, + error TEXT, + duration_ms INT, + created_at TIMESTAMPTZ NOT NULL DEFAULT now() +); +CREATE INDEX webhook_deliveries_webhook_id_idx ON webhook_deliveries(webhook_id); +CREATE INDEX webhook_deliveries_created_at_idx ON webhook_deliveries(created_at DESC); @@ -234,6 +234,30 @@ pub struct CommitDay { pub count: i32, } +#[derive(Debug, Clone, FromRow, Serialize)] +pub struct Webhook { + pub id: Uuid, + pub repo_id: Uuid, + pub url: String, + pub secret: String, + pub events: Vec<String>, + pub active: bool,
Large diffs are not rendered by default. Showing the first 50 of 979 lines. Show full diff