chore: remove obsolete APIs (register, probe, n8n, videos, people)

- Remove /api/v1/register (replaced by /api/v1/files/register)
- Remove /api/v1/probe (replaced by /api/v1/files/:uuid)
- Remove /api/v1/n8n/... (n8n workflow only)
- Remove /api/v1/unregister (high risk)
- Remove /api/v1/videos list (replaced by /api/v1/files)
- Remove /api/v1/people (merged into /api/v1/identities)
- Clean up dead code and unused structs
This commit is contained in:
Warren
2026-04-30 22:16:24 +08:00
parent b54c2def30
commit ee81e343ce
9 changed files with 1386 additions and 1188 deletions

View File

@@ -12,17 +12,6 @@ use crate::core::db::ResourceRecord;
pub fn identity_routes() -> Router<crate::api::server::AppState> {
Router::new()
.route("/api/v1/people", get(list_people))
.route("/api/v1/people/search", post(search_people))
.route("/api/v1/people/candidates", get(list_candidates))
.route(
"/api/v1/people/:identity_id/confirm-candidate",
post(confirm_candidate),
)
.route(
"/api/v1/people/:identity_id/reject-candidate",
post(reject_candidate),
)
.route("/api/v1/files", get(list_files))
.route("/api/v1/files/:uuid", get(get_file_detail))
.route("/api/v1/files/:uuid/identities", get(get_file_identities))
@@ -34,213 +23,6 @@ pub fn identity_routes() -> Router<crate::api::server::AppState> {
.route("/api/v1/resources", get(list_resources))
}
// ... (Keep existing functions) ...
// --- People / Identity Endpoints ---
#[derive(Debug, Deserialize)]
pub struct PeopleQuery {
page: Option<usize>,
page_size: Option<usize>,
}
#[derive(Debug, Serialize)]
pub struct PeopleResponse {
pub success: bool,
pub total: i64,
pub page: usize,
pub page_size: usize,
pub data: Vec<PeopleItem>,
}
#[derive(Debug, Serialize)]
pub struct PeopleItem {
pub identity_id: Uuid,
pub name: String,
pub metadata: serde_json::Value,
pub created_at: Option<chrono::DateTime<chrono::Utc>>,
}
async fn list_people(
State(state): State<crate::api::server::AppState>,
Query(params): Query<PeopleQuery>,
) -> Result<Json<PeopleResponse>, (StatusCode, String)> {
let page = params.page.unwrap_or(1);
let page_size = params.page_size.unwrap_or(20);
let offset = ((page - 1) as i64) * (page_size as i64);
let records = state
.db
.list_people(page_size as i32, offset)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
// TODO: Get total count
let total = 100; // Placeholder
let data = records
.into_iter()
.map(|r| PeopleItem {
identity_id: r.uuid,
name: r.name,
metadata: r.metadata,
created_at: r.created_at,
})
.collect();
Ok(Json(PeopleResponse {
success: true,
total,
page,
page_size,
data,
}))
}
#[derive(Debug, Deserialize)]
pub struct SearchPeopleRequest {
pub query: String,
pub page: Option<usize>,
pub page_size: Option<usize>,
}
async fn search_people(
State(state): State<crate::api::server::AppState>,
Json(req): Json<SearchPeopleRequest>,
) -> Result<Json<PeopleResponse>, (StatusCode, String)> {
let page = req.page.unwrap_or(1);
let page_size = req.page_size.unwrap_or(20);
let offset = ((page - 1) as i64) * (page_size as i64);
let records = state
.db
.search_people(&req.query, page_size as i32, offset)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
let data: Vec<PeopleItem> = records
.into_iter()
.map(|r| PeopleItem {
identity_id: r.uuid,
name: r.name,
metadata: r.metadata,
created_at: r.created_at,
})
.collect();
Ok(Json(PeopleResponse {
success: true,
total: data.len() as i64, // Approximation
page,
page_size,
data,
}))
}
#[derive(Debug, Deserialize)]
pub struct CandidatesQuery {
page: Option<usize>,
page_size: Option<usize>,
}
#[derive(Debug, Serialize)]
pub struct CandidatesResponse {
pub success: bool,
pub total: i64,
pub page: usize,
pub page_size: usize,
pub data: Vec<CandidateItem>,
}
#[derive(Debug, Serialize)]
pub struct CandidateItem {
pub pre_chunk_id: i64,
pub file_uuid: Uuid,
pub data: serde_json::Value,
}
async fn list_candidates(
State(state): State<crate::api::server::AppState>,
Query(params): Query<CandidatesQuery>,
) -> Result<Json<CandidatesResponse>, (StatusCode, String)> {
let page = params.page.unwrap_or(1);
let page_size = params.page_size.unwrap_or(20);
let offset = ((page - 1) as i64) * (page_size as i64);
let records = state
.db
.get_people_candidates(page_size as i32, offset)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
let data = records
.into_iter()
.map(|r| CandidateItem {
pre_chunk_id: r.id,
file_uuid: r.file_uuid,
data: r.data,
})
.collect();
Ok(Json(CandidatesResponse {
success: true,
total: 0, // TODO
page,
page_size,
data,
}))
}
// --- Candidate Workflow Endpoints ---
#[derive(Debug, Deserialize)]
pub struct ConfirmCandidateRequest {
pub pre_chunk_id: i64,
}
#[derive(Debug, Serialize)]
pub struct ConfirmCandidateResponse {
pub success: bool,
pub message: String,
}
async fn confirm_candidate(
State(state): State<crate::api::server::AppState>,
Path(identity_id_str): Path<String>,
Json(req): Json<ConfirmCandidateRequest>,
) -> Result<Json<ConfirmCandidateResponse>, (StatusCode, String)> {
let identity_id = Uuid::parse_str(&identity_id_str)
.map_err(|e| (StatusCode::BAD_REQUEST, format!("Invalid UUID: {}", e)))?;
state
.db
.confirm_candidate(req.pre_chunk_id, identity_id)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
Ok(Json(ConfirmCandidateResponse {
success: true,
message: "Candidate confirmed and linked to identity".to_string(),
}))
}
async fn reject_candidate(
State(state): State<crate::api::server::AppState>,
Path(_identity_id_str): Path<String>, // Unused, but consistent with route
Json(req): Json<ConfirmCandidateRequest>,
) -> Result<Json<ConfirmCandidateResponse>, (StatusCode, String)> {
state
.db
.reject_candidate(req.pre_chunk_id)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
Ok(Json(ConfirmCandidateResponse {
success: true,
message: "Candidate rejected".to_string(),
}))
}
// --- Files Endpoints ---
#[derive(Debug, Deserialize)]

File diff suppressed because it is too large Load Diff

View File

@@ -209,7 +209,7 @@ impl From<VideoRow> for VideoRecord {
width: row.width.unwrap_or(0) as u32,
height: row.height.unwrap_or(0) as u32,
fps: row.fps.unwrap_or(0.0),
probe_json: row.probe_json.map(|v| v.to_string()),
probe_json: row.probe_json,
storage: StorageStatus {
fs_video: row.fs_video.unwrap_or(false),
fs_json: row.fs_json.unwrap_or(false),
@@ -243,7 +243,7 @@ pub struct VideoRecord {
pub width: u32,
pub height: u32,
pub fps: f64,
pub probe_json: Option<String>,
pub probe_json: Option<serde_json::Value>,
pub storage: StorageStatus,
pub status: VideoStatus,
pub processing_status: Option<serde_json::Value>,
@@ -695,7 +695,7 @@ impl PostgresDb {
}
// Videos
sqlx::query("CREATE TABLE IF NOT EXISTS videos (id SERIAL PRIMARY KEY, file_uuid VARCHAR(32) UNIQUE NOT NULL, file_path TEXT NOT NULL, file_name TEXT NOT NULL, duration DOUBLE PRECISION, width INTEGER, height INTEGER, fps DOUBLE PRECISION, probe_json TEXT, fs_video BOOLEAN DEFAULT FALSE, fs_json BOOLEAN DEFAULT FALSE, psql_chunk BOOLEAN DEFAULT FALSE, pobject_chunk BOOLEAN DEFAULT FALSE, mobject_chunk BOOLEAN DEFAULT FALSE, pvector_chunk BOOLEAN DEFAULT FALSE, qvector_chunk BOOLEAN DEFAULT FALSE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)").execute(pool).await?;
sqlx::query("CREATE TABLE IF NOT EXISTS videos (id SERIAL PRIMARY KEY, file_uuid VARCHAR(32) UNIQUE NOT NULL, file_path TEXT NOT NULL, file_name TEXT NOT NULL, duration DOUBLE PRECISION, width INTEGER, height INTEGER, fps DOUBLE PRECISION, probe_json jsonb, fs_video BOOLEAN DEFAULT FALSE, fs_json BOOLEAN DEFAULT FALSE, psql_chunk BOOLEAN DEFAULT FALSE, pobject_chunk BOOLEAN DEFAULT FALSE, mobject_chunk BOOLEAN DEFAULT FALSE, pvector_chunk BOOLEAN DEFAULT FALSE, qvector_chunk BOOLEAN DEFAULT FALSE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)").execute(pool).await?;
sqlx::query("CREATE INDEX IF NOT EXISTS idx_videos_file_uuid ON videos(file_uuid)")
.execute(pool)
.await?;

View File

@@ -171,7 +171,7 @@ impl IngestionService {
width,
height,
fps,
probe_json: Some(probe_json_str),
probe_json: serde_json::from_str(&probe_json_str).ok(),
storage: Default::default(),
status: VideoStatus::Pending,
processing_status: Some(serde_json::json!({"phase": "REGISTERED"})),

View File

@@ -967,7 +967,7 @@ async fn main() -> Result<()> {
width,
height,
fps,
probe_json: Some(json_str),
probe_json: serde_json::from_str(&json_str).ok(),
storage: Default::default(),
status: VideoStatus::Pending,
processing_status: Some(serde_json::json!({"phase": "REGISTERED"})),