Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4fa4de7
app/: transactional emails (sc-8900): today's every Kind and render p…
ndbroadbent Dec 2, 2026
67a507e
Emails: the delivery job pushes a heartbeat that checks the work (VIS…
ndbroadbent Dec 2, 2026
246f12b
Emails, review fixes: each email is claimed just before it's sent (a …
ndbroadbent Dec 2, 2026
efc2724
Rebased on main: Cargo.lock resolved from main's, and the boot checks…
ndbroadbent Dec 2, 2026
323975e
app/: Stripe's webhook (sc-8900, billing): signed events only (t=,v1=…
ndbroadbent Dec 2, 2026
1b05d8b
app/: the billing page's routes (sc-8900, billing 2): plans, Checkout…
ndbroadbent Dec 2, 2026
d73cb1d
Billing, review fixes: production refuses to boot on a Stripe test ke…
ndbroadbent Dec 2, 2026
6db80c3
Rebased on main: Cargo.lock resolved from main's, and the boot checks…
ndbroadbent Dec 2, 2026
5a91637
app/: personal and project tokens in the web app (sc-8900): list, mak…
ndbroadbent Dec 2, 2026
db21706
Tokens, review fixes: the security notice's dedupe key is the new tok…
ndbroadbent Dec 2, 2026
adbcc00
app/: invitations and members (sc-8900): invite by email or GitHub lo…
ndbroadbent Dec 2, 2026
5f6fab8
Invitations, review fixes: staff are no admins of organizations they …
ndbroadbent Dec 2, 2026
33a4379
Rebased on main: Cargo.lock resolved from main's, and the boot checks…
ndbroadbent Dec 2, 2026
319aaa3
app/: the person's own page (sc-8900): GET /api/ui/me (who they are, …
ndbroadbent Dec 2, 2026
a1e326d
Me, review fixes: /me says which forges people can sign in with (an O…
ndbroadbent Dec 2, 2026
c62e65e
Test: a signed-out /api/ui/me asks for JSON, as the React app does (a…
ndbroadbent Dec 2, 2026
c61495c
app/: visualci login's device-code sign-in (sc-8900): POST /api/v1/de…
ndbroadbent Dec 2, 2026
4dac226
Device sign-in, review fixes: the approval page leads with a fixed 'V…
ndbroadbent Dec 2, 2026
a2d4283
Test: a signed-out device page request asks for JSON, as the React ap…
ndbroadbent Dec 2, 2026
c1f5c13
Rebased on main: Cargo.lock resolved from main's, and the boot checks…
ndbroadbent Dec 2, 2026
e33c027
Device sign-in: its CLI routes in http/api/mod.rs, where main's API r…
ndbroadbent Dec 2, 2026
6ebd5c5
Rebased on main: Cargo.lock resolved from main's, and the boot checks…
ndbroadbent Dec 2, 2026
fb2ec24
app/: staff pages for sign-ups and emails (sc-8900): the latest 100 s…
ndbroadbent Dec 2, 2026
e7bfd25
app/: creating an organization (sc-8900): its creator is its admin, s…
ndbroadbent Dec 2, 2026
67a3b0f
app/: plain functions for the MCP server's tools (sc-8900): invitatio…
ndbroadbent Dec 2, 2026
7e21ee4
app/: GitHub's webhook (sc-8900, forge): signed deliveries only (X-Hu…
ndbroadbent Dec 2, 2026
2e4745d
GitHub webhook, review fixes: a recheck lists each linked repository'…
ndbroadbent Dec 2, 2026
38a4500
Rebased on main: Cargo.lock resolved from main's, and the boot checks…
ndbroadbent Dec 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 214 additions & 10 deletions app/Cargo.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ path = "src/main.rs"
laravel-rust = { version = "=0.1.4", features = ["database-postgres", "minijinja"] }
# The same axum Laravel Rust runs on, for extractors (auth::Principal)
axum = "0.8"
base64 = "0.22"
hex = "0.4"
oauth-provider = "0.1.3"
oauth-provider-laravel = { version = "=0.1.1", features = ["postgres"] }
hmac = "0.12"
jsonwebtoken = "9"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"
Expand All @@ -44,9 +47,17 @@ snapshot-diff = { path = "../crates/snapshot-diff" }

[dev-dependencies]
regex = "1"
# A GitHub App key made at test time, so no private key is committed
rsa = { version = "0.9", features = ["pem"] }

[profile.dev]
debug = "line-tables-only"

[profile.dev.package."*"]
debug = false

# Generating the tests' RSA key is slow unoptimised
[profile.dev.package.num-bigint-dig]
opt-level = 3
[profile.dev.package.rsa]
opt-level = 3
37 changes: 37 additions & 0 deletions app/database/migrations/2026_12_03_000300_create_emails_table.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use laravel::db::AnyTransaction;

/// The emails outbox (ported as today's), and each person's email choices and sign-up notice.
pub async fn migrate(tx: &mut AnyTransaction<'_>) -> laravel::Result<()> {
tx.query(
"CREATE TABLE emails (
id BIGSERIAL PRIMARY KEY,
kind TEXT NOT NULL,
dedupe_key TEXT NOT NULL UNIQUE,
organization_id BIGINT REFERENCES organizations(id) ON DELETE CASCADE,
user_id BIGINT REFERENCES users(id) ON DELETE CASCADE,
recipient TEXT NOT NULL,
data JSONB NOT NULL,
subject TEXT,
text_body TEXT,
html_body TEXT,
state TEXT NOT NULL DEFAULT 'pending' CHECK (state IN ('pending', 'sent', 'failed')),
attempts INTEGER NOT NULL DEFAULT 0,
last_error TEXT,
claimed_at TIMESTAMPTZ,
sent_at TIMESTAMPTZ,
dismissed_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX emails_pending ON emails (created_at) WHERE state = 'pending';
CREATE INDEX emails_organization ON emails (organization_id, created_at);
CREATE INDEX emails_failed ON emails (id) WHERE state = 'failed' AND dismissed_at IS NULL;
ALTER TABLE users
ADD COLUMN email_low_credits BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN email_receipts BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN signup_notified_at TIMESTAMPTZ;",
)
.unprepared()
.await?;
Ok(())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use laravel::db::AnyTransaction;

/// Invitations to an organization, by email or by a login on a forge (ported as today's). `for_user_id` is the
/// account it's for when one existed when it was sent, so it shows on their side; it waits for them to accept.
pub async fn migrate(tx: &mut AnyTransaction<'_>) -> laravel::Result<()> {
tx.query(
"CREATE TABLE invitations (
id BIGSERIAL PRIMARY KEY,
pid UUID NOT NULL UNIQUE,
organization_id BIGINT NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
email TEXT,
forge TEXT,
login TEXT,
role TEXT NOT NULL CHECK (role IN ('admin', 'member', 'read')),
invited_by BIGINT REFERENCES users(id) ON DELETE SET NULL,
accepted_by BIGINT REFERENCES users(id) ON DELETE SET NULL,
accepted_at TIMESTAMPTZ,
for_user_id BIGINT REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CHECK ((email IS NOT NULL) <> (login IS NOT NULL)),
CHECK ((login IS NULL) = (forge IS NULL))
);
CREATE UNIQUE INDEX invitations_pending_email ON invitations (organization_id, lower(email))
WHERE accepted_at IS NULL AND email IS NOT NULL;
CREATE UNIQUE INDEX invitations_pending_login ON invitations (organization_id, forge, lower(login))
WHERE accepted_at IS NULL AND login IS NOT NULL;
CREATE INDEX invitations_for_user ON invitations (for_user_id) WHERE accepted_at IS NULL;",
)
.unprepared()
.await?;
Ok(())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use laravel::db::AnyTransaction;

/// "How did you hear about VisualCI?" (asked once after sign-up), ported as today's.
pub async fn migrate(tx: &mut AnyTransaction<'_>) -> laravel::Result<()> {
tx.query(
"ALTER TABLE users
ADD COLUMN heard_about_pending BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN heard_about_source TEXT,
ADD COLUMN heard_about_detail TEXT;
CREATE INDEX users_signup_unnotified ON users (id) WHERE signup_notified_at IS NULL;",
)
.unprepared()
.await?;
Ok(())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use laravel::db::AnyTransaction;

/// `visualci login`'s device-code sign-in (ported as today's): the device code is stored hashed; a code gives one
/// token, once.
pub async fn migrate(tx: &mut AnyTransaction<'_>) -> laravel::Result<()> {
tx.query(
"CREATE TABLE device_logins (
id BIGSERIAL PRIMARY KEY,
device_code_hash TEXT NOT NULL UNIQUE,
user_code TEXT NOT NULL UNIQUE,
-- What's asking, shown on the approval page: \"visualci CLI on ada-laptop\".
client_name TEXT NOT NULL,
-- Who asked for it (behind the trusted proxies, the address they report), shown on the approval page and
-- counted for the per-address limit.
requester_ip TEXT,
last_polled_at TIMESTAMPTZ,
user_id BIGINT REFERENCES users(id) ON DELETE CASCADE,
approved_at TIMESTAMPTZ,
denied_at TIMESTAMPTZ,
-- When the CLI collected its token.
consumed_at TIMESTAMPTZ,
expires_at TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX device_logins_requester ON device_logins (requester_ip, created_at);",
)
.unprepared()
.await?;
Ok(())
}
Loading
Loading