fix: identity binding + JSON endpoint + Phase 5 test script
- identity_binding.rs: fix i32->i64 type mismatch, COALESCE name column - identity_api.rs: get_identity_json fallback to DB if file missing - test_m5api_phase5.sh: fixed variable expansion, updated request bodies - Phase 5: 21/23 passed (2 known: multipart + proxy 404)
This commit is contained in:
@@ -76,8 +76,8 @@ pub async fn bind_identity(
|
||||
})?;
|
||||
|
||||
// Get identity_id from identity_uuid
|
||||
let identity_row: Option<(i32, String)> = sqlx::query_as(&format!(
|
||||
"SELECT id, name FROM {} WHERE uuid = $1::uuid",
|
||||
let identity_row: Option<(i64, String)> = sqlx::query_as(&format!(
|
||||
"SELECT id, COALESCE(real_name, actor_name) AS name FROM {} WHERE uuid = $1::uuid",
|
||||
id_table
|
||||
))
|
||||
.bind(&identity_uuid)
|
||||
@@ -170,7 +170,7 @@ pub async fn unbind_identity(
|
||||
|
||||
/// V4.0 合併:將 identity A 合併入 identity B,A 被刪除
|
||||
pub async fn merge_identities(
|
||||
Path(from_uuid): Path<String>,
|
||||
Path(identity_uuid): Path<String>,
|
||||
Json(req): Json<MergeIdentitiesRequest>,
|
||||
) -> Result<Json<ApiResponse<serde_json::Value>>, (StatusCode, Json<serde_json::Value>)> {
|
||||
let face_table = crate::core::db::schema::table_name("face_detections");
|
||||
@@ -186,11 +186,11 @@ pub async fn merge_identities(
|
||||
})?;
|
||||
|
||||
// Get IDs for both identities
|
||||
let from_row: Option<(i32, String)> = sqlx::query_as(&format!(
|
||||
"SELECT id, name FROM {} WHERE uuid = $1::uuid",
|
||||
let from_row: Option<(i64, String)> = sqlx::query_as(&format!(
|
||||
"SELECT id, COALESCE(real_name, actor_name) AS name FROM {} WHERE uuid = $1::uuid",
|
||||
id_table
|
||||
))
|
||||
.bind(&from_uuid)
|
||||
.bind(&identity_uuid)
|
||||
.fetch_optional(&db)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
@@ -204,8 +204,8 @@ pub async fn merge_identities(
|
||||
Json(serde_json::json!({"error": "Source identity not found"})),
|
||||
))?;
|
||||
|
||||
let into_row: Option<(i32, String)> = sqlx::query_as(&format!(
|
||||
"SELECT id, name FROM {} WHERE uuid = $1::uuid",
|
||||
let into_row: Option<(i64, String)> = sqlx::query_as(&format!(
|
||||
"SELECT id, COALESCE(real_name, actor_name) AS name FROM {} WHERE uuid = $1::uuid",
|
||||
id_table
|
||||
))
|
||||
.bind(&req.into_uuid)
|
||||
@@ -301,7 +301,7 @@ pub fn identity_binding_routes() -> Router<crate::api::server::AppState> {
|
||||
post(unbind_identity),
|
||||
)
|
||||
.route(
|
||||
"/api/v1/identity/:from_uuid/mergeinto",
|
||||
"/api/v1/identity/:identity_uuid/mergeinto",
|
||||
post(merge_identities),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user