mirror of
https://github.com/FluxaMedia/fluxa-core.git
synced 2026-08-06 08:48:49 +00:00
fix(core): preserve a catalog extra's default value through manifest parsing
parse_catalogs rebuilds each catalog's extra list from scratch and only whitelisted name/options/isRequired/optionsLimit, silently dropping "default" -- the field a required extra (e.g. TMDB By Year's "genre", really a year picker) needs so the client can pre-select it. This is upstream of both catalog_extras() and CatalogExtra's Kotlin model; those were already correct but had nothing to read since the field never survived this far. Confirmed against the live addon manifest that reports "default":"2026" for that catalog.
This commit is contained in:
parent
2eef332451
commit
dfde4e90f3
1 changed files with 13 additions and 1 deletions
|
|
@ -459,6 +459,14 @@ pub(crate) fn parse_catalogs(json: &Value) -> Vec<Value> {
|
|||
json!(options_limit as i32),
|
||||
);
|
||||
}
|
||||
if let Some(default_value) =
|
||||
extra_object.get("default").and_then(Value::as_str)
|
||||
{
|
||||
map.insert(
|
||||
"default".to_string(),
|
||||
Value::String(default_value.to_string()),
|
||||
);
|
||||
}
|
||||
Some(Value::Object(map))
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
|
|
@ -1000,7 +1008,7 @@ mod tests {
|
|||
"resources":["catalog",{"name":"stream","types":["movie"],"idPrefixes":["tt"]}],
|
||||
"types":["movie","series"],
|
||||
"idPrefixes":["tt"],
|
||||
"catalogs":[{"type":"movie","id":"top","name":"Top","extra":[{"name":"genre","isRequired":false,"options":["Drama"],"optionsLimit":2}],"extraSupported":["search"],"extraRequired":["genre"]}],
|
||||
"catalogs":[{"type":"movie","id":"top","name":"Top","extra":[{"name":"genre","isRequired":false,"options":["Drama"],"optionsLimit":2,"default":"Drama"}],"extraSupported":["search"],"extraRequired":["genre"]}],
|
||||
"addonCatalogs":[{"type":"addon","id":"community","name":"Community"}],
|
||||
"config":[{"key":"token","type":"password","default":"x","title":"Token","required":true}],
|
||||
"background":"/bg.jpg",
|
||||
|
|
@ -1029,6 +1037,10 @@ mod tests {
|
|||
manifest["catalogs"][0]["extraRequired"][0].as_str(),
|
||||
Some("genre")
|
||||
);
|
||||
assert_eq!(
|
||||
manifest["catalogs"][0]["extra"][0]["default"].as_str(),
|
||||
Some("Drama")
|
||||
);
|
||||
assert_eq!(
|
||||
manifest["logo"].as_str(),
|
||||
Some("https://addon.example/root/logo.png")
|
||||
|
|
|
|||
Loading…
Reference in a new issue