Add request approval system and audiobook path template

Implements admin approval workflow for user requests with global and per-user auto-approve controls. Adds new request statuses ('awaiting_approval', 'denied'), related API endpoints, and UI for pending approvals. Introduces configurable audiobook organization path template with validation and preview in settings, updates database schema and migrations for new fields.
This commit is contained in:
kikootwo
2026-01-16 13:47:36 -05:00
parent 428d9a12e0
commit 3a9ae4a439
59 changed files with 4043 additions and 256 deletions
@@ -0,0 +1,17 @@
-- Add audiobook path template configuration
-- This allows admin to customize the folder/file path template for organized audiobooks
-- Template supports placeholders: {author}, {title}, {asin}
-- Insert default configuration for audiobook path template
INSERT INTO configuration (id, key, value, encrypted, category, description, created_at, updated_at)
VALUES (
gen_random_uuid(),
'audiobook_path_template',
'{author}/{title} {asin}',
false,
'automation',
'Template for organizing audiobook file paths. Supports placeholders: {author}, {title}, {asin}. Example: "{author}/{title} {asin}" creates "Author Name/Book Title ASIN/audiobook.m4b"',
NOW(),
NOW()
)
ON CONFLICT (key) DO NOTHING;
@@ -0,0 +1,2 @@
-- AddYearToAudiobook
ALTER TABLE "audiobooks" ADD COLUMN "year" INTEGER;
+5 -1
View File
@@ -49,6 +49,9 @@ model User {
bookDateCustomPrompt String? @map("bookdate_custom_prompt") @db.Text
bookDateOnboardingComplete Boolean @default(false) @map("bookdate_onboarding_complete")
// Request approval preferences
autoApproveRequests Boolean? @map("auto_approve_requests") // null = use global setting, true = auto-approve, false = require approval
// Soft delete support
deletedAt DateTime? @map("deleted_at")
deletedBy String? @map("deleted_by") // Admin user ID who deleted this user
@@ -162,6 +165,7 @@ model Audiobook {
narrator String?
description String? @db.Text
coverArtUrl String? @map("cover_art_url") @db.Text
year Int? // Release year extracted from releaseDate
// Request tracking
status String @default("requested") // requested, downloading, processing, completed, failed
@@ -199,7 +203,7 @@ model Request {
userId String @map("user_id")
audiobookId String @map("audiobook_id")
status String @default("pending")
// Status values: pending, searching, downloading, processing, downloaded, available, failed, cancelled, awaiting_search, awaiting_import, warn
// Status values: pending, awaiting_approval, denied, searching, downloading, processing, downloaded, available, failed, cancelled, awaiting_search, awaiting_import, warn
// Flow: pending → searching → downloading → processing → downloaded → available (when matched in Plex)
progress Int @default(0) // 0-100
priority Int @default(0)