Wires the analyze_page job kind into the page-create paths and adds admin controls, all gated on a new ANALYSIS_ENABLED flag (AppState.analysis_enabled, config::AnalysisConfig): - Chapter upload (api::chapters) enqueues one analyze_page job per page after the tx commits (best-effort; failures logged, never fatal). - Crawler content sync (persist_pages → RETURNING id) enqueues per persisted page when the daemon dispatcher's analysis_enabled flag is set; threaded through sync_chapter_content (CLI/resync pass false). - repo::page_analysis::enqueue_all_pages: bulk backfill via INSERT..SELECT, skipping done pages (only_unanalyzed) and existing pending jobs. - New admin endpoints (RequireAdmin, 503 when disabled, audited): POST /admin/analysis/reenqueue and POST /admin/pages/:id/analyze (force). Tests: upload enqueues N jobs / no-op when disabled; crawler persist_pages enqueue gate; admin reenqueue (backfill, idempotent, only-unanalyzed, 503, non-admin 403) and force-analyze (force flag, 404). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
703 B
Rust
27 lines
703 B
Rust
//! Admin-only endpoints. Mounted under `/api/v1/admin/*` by
|
|
//! `crate::api::routes`. Every handler in this subtree is guarded by
|
|
//! `RequireAdmin`, which only accepts session-cookie authentication —
|
|
//! bot/API tokens cannot reach admin routes (see
|
|
//! `crate::auth::extractor::RequireAdmin`).
|
|
|
|
pub mod analysis;
|
|
pub mod crawler;
|
|
pub mod mangas;
|
|
pub mod resync;
|
|
pub mod system;
|
|
pub mod users;
|
|
|
|
use axum::Router;
|
|
|
|
use crate::app::AppState;
|
|
|
|
pub fn routes() -> Router<AppState> {
|
|
Router::new()
|
|
.merge(users::routes())
|
|
.merge(mangas::routes())
|
|
.merge(resync::routes())
|
|
.merge(system::routes())
|
|
.merge(crawler::routes())
|
|
.merge(analysis::routes())
|
|
}
|