feat: Identity JSON sync + schema-aware column selection

- storage.rs: add local_profile field, check disk for profile.jpg
- tmdb_api.rs: trigger JSON sync after TMDb probe
- identity_api.rs: upload_profile_image triggers JSON sync
- identity_binding.rs: bind/unbind/merge trigger JSON sync
- get_identity_json: Lazy Sync (generates JSON from DB if missing)
- identities.rs + identity_api.rs: use schema-aware column selection (dev:name vs public:real_name)
- Fixes 500 errors on identities endpoints across schemas
This commit is contained in:
Accusys
2026-05-19 23:10:49 +08:00
parent 0eb08acaae
commit ba68cd2548
3 changed files with 21 additions and 14 deletions

View File

@@ -187,15 +187,18 @@ pub async fn save_identity_file_by_pool(pool: &sqlx::PgPool, uuid: &str) -> Resu
let identity_table = crate::core::db::schema::table_name("identities");
let fd_table = crate::core::db::schema::table_name("face_detections");
// Schema-aware column selection: dev uses 'name', public uses 'real_name'
let name_col = if identity_table.starts_with("dev.") { "name" } else { "real_name" };
let clean = uuid.replace('-', "");
let record = sqlx::query_as::<_, crate::core::db::IdentityDetailRecord>(
&format!(
"SELECT id, uuid::text, COALESCE(real_name, actor_name, name) AS name, identity_type, source, status, metadata, reference_data, \
"SELECT id, uuid::text, {} AS name, identity_type, source, status, metadata, reference_data, \
NULL::real[] as voice_embedding, NULL::real[] as identity_embedding, \
face_embedding::real[] as face_embedding, \
tmdb_id, tmdb_profile, created_at::timestamptz as created_at, NULL::timestamptz as updated_at \
FROM {} WHERE REPLACE(uuid::text, '-', '') = $1",
identity_table
name_col, identity_table
)
)
.bind(&clean)