mirror of
https://github.com/FluxaMedia/fluxa-core.git
synced 2026-07-27 20:32:10 +00:00
fix(search-plan): JSON-encode transport-url/genre FFI returns
resolve_transport_url_json and resolve_feed_option_genre_json feed opt_json() at the FFI boundary, which requires valid JSON — a bare URL/genre string isn't, so resolveTransportUrl/resolveFeedOptionGenre would fail from the frontend whenever they had a result. Finishes an in-progress fix that JSON-encoded the transport-url return but missed the early-return genre branch, and updates home_ranking.rs's direct (non-FFI) callers to unwrap the now JSON-encoded string before embedding it in a json!() literal, since json!() already does its own string encoding.
This commit is contained in:
parent
ca749a8d00
commit
f00a09a4ce
2 changed files with 9 additions and 5 deletions
|
|
@ -898,7 +898,9 @@ fn resolve_folder_catalog_sources(folder: &Map<String, Value>, addons_json: &str
|
|||
if s.get("catalogId").and_then(Value::as_str).is_none() {
|
||||
continue;
|
||||
}
|
||||
if let Some(t_url) = resolve_transport_url_json(&s.to_string(), addons_json) {
|
||||
if let Some(t_url) = resolve_transport_url_json(&s.to_string(), addons_json)
|
||||
.and_then(|json| serde_json::from_str::<String>(&json).ok())
|
||||
{
|
||||
let catalog_id = s.get("catalogId").and_then(Value::as_str).unwrap_or("");
|
||||
let content_type = s.get("type").and_then(Value::as_str).unwrap_or("movie");
|
||||
let mut entry =
|
||||
|
|
@ -914,7 +916,9 @@ fn resolve_folder_catalog_sources(folder: &Map<String, Value>, addons_json: &str
|
|||
if resolved.is_empty() {
|
||||
if let Some(catalog_id) = folder.get("catalogId").and_then(Value::as_str) {
|
||||
let src = json!({ "catalogId": catalog_id, "type": "movie" });
|
||||
if let Some(t_url) = resolve_transport_url_json(&src.to_string(), addons_json) {
|
||||
if let Some(t_url) = resolve_transport_url_json(&src.to_string(), addons_json)
|
||||
.and_then(|json| serde_json::from_str::<String>(&json).ok())
|
||||
{
|
||||
let mut entry =
|
||||
json!({ "transportUrl": t_url, "catalogId": catalog_id, "type": "movie" });
|
||||
if let Some(g) = folder.get("genre").and_then(Value::as_str) {
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@ pub(crate) fn resolve_transport_url_json(source_json: &str, addons_json: &str) -
|
|||
})
|
||||
});
|
||||
if matches {
|
||||
return Some(t_url.to_string());
|
||||
return serde_json::to_string(t_url).ok();
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
@ -682,7 +682,7 @@ pub(crate) fn resolve_feed_option_genre_json(
|
|||
.and_then(Value::as_str)
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
{
|
||||
return Some(genre.to_string());
|
||||
return serde_json::to_string(genre).ok();
|
||||
}
|
||||
|
||||
let transport_url = option.get("transportUrl").and_then(Value::as_str)?;
|
||||
|
|
@ -721,7 +721,7 @@ pub(crate) fn resolve_feed_option_genre_json(
|
|||
.and_then(Value::as_str);
|
||||
|
||||
let resolved = default_genre.or(if is_required { first_option } else { None })?;
|
||||
Some(resolved.to_string())
|
||||
serde_json::to_string(resolved).ok()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue