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:
@@ -199,7 +199,7 @@ struct N8nSearchHit {
|
||||
text: String,
|
||||
score: f32,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
media_url: Option<String>,
|
||||
file_path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -840,7 +840,6 @@ async fn n8n_search(
|
||||
qdrant.search(&query_vector, limit).await?
|
||||
};
|
||||
|
||||
let media_base = crate::core::config::MEDIA_BASE_URL.as_str();
|
||||
let mut hits = Vec::new();
|
||||
|
||||
for r in search_results {
|
||||
@@ -859,11 +858,11 @@ async fn n8n_search(
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
|
||||
let media_url = if chunk.uuid.is_empty() {
|
||||
let file_path = if chunk.uuid.is_empty() {
|
||||
None
|
||||
} else {
|
||||
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 {
|
||||
@@ -878,7 +877,7 @@ async fn n8n_search(
|
||||
},
|
||||
text,
|
||||
score: r.score,
|
||||
media_url,
|
||||
file_path,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user