fix: return file_path instead of media_url in n8n search API

The media_url was constructed using MEDIA_BASE_URL which returned
404s. Now returns actual file_path from database for n8n workflow.
This commit is contained in:
Warren
2026-03-25 17:24:29 +08:00
parent ceb33877ff
commit 80399b1c12

View File

@@ -199,7 +199,7 @@ struct N8nSearchHit {
text: String, text: String,
score: f32, score: f32,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
media_url: Option<String>, file_path: Option<String>,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
@@ -840,7 +840,6 @@ async fn n8n_search(
qdrant.search(&query_vector, limit).await? qdrant.search(&query_vector, limit).await?
}; };
let media_base = crate::core::config::MEDIA_BASE_URL.as_str();
let mut hits = Vec::new(); let mut hits = Vec::new();
for r in search_results { for r in search_results {
@@ -859,11 +858,11 @@ async fn n8n_search(
.unwrap_or("") .unwrap_or("")
.to_string(); .to_string();
let media_url = if chunk.uuid.is_empty() { let file_path = if chunk.uuid.is_empty() {
None None
} else { } else {
let video = pg.get_video_by_uuid(&chunk.uuid).await.ok().flatten(); let video = pg.get_video_by_uuid(&chunk.uuid).await.ok().flatten();
video.map(|v| format!("{}/{}", media_base, v.file_name)) video.map(|v| v.file_path)
}; };
hits.push(N8nSearchHit { hits.push(N8nSearchHit {
@@ -878,7 +877,7 @@ async fn n8n_search(
}, },
text, text,
score: r.score, score: r.score,
media_url, file_path,
}); });
} }
} }