Files
silo-server/web/src/lib/quotaPeriods.ts
QuickandClaude Fable 5 ed4cebf3ba feat(ai): per-user transcription quota for subtitle ASR jobs
Cap how many Whisper transcription jobs each user account can start per
rolling window (day/week/month), configurable from admin settings. The
player modal shows remaining usage and the server returns 429 with
details when the limit is hit.

Enforcement is atomic with the job insert (per-user advisory lock, same
pattern as media-request quotas), so concurrent requests cannot race
past the limit. Failed/cancelled jobs that never produced transcription
work are refunded. Exemption applies to the admin account's primary
profile only; other profiles on an admin account stay subject to the
quota. A partial index covers the quota count, a malformed quota
setting row degrades to "no quota" instead of blocking startup, and the
period vocabulary and admin-role predicate are each defined once
(ai.ValidQuotaPeriod, apimw.IsAdmin).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 16:02:42 -04:00

11 lines
403 B
TypeScript

// Rolling-window labels for the subtitle-AI transcription quota periods.
// One source of truth for every surface that names a period; keep in sync
// with QuotaPeriodWindow in internal/subtitles/ai/quota.go.
export const QUOTA_PERIODS = ["day", "week", "month"] as const;
export const QUOTA_PERIOD_WINDOW_LABELS: Record<string, string> = {
day: "24 hours",
week: "7 days",
month: "30 days",
};