diff --git a/crates/nzb-web/src/sabnzbd_compat.rs b/crates/nzb-web/src/sabnzbd_compat.rs index 399e1dc..cdb661e 100644 --- a/crates/nzb-web/src/sabnzbd_compat.rs +++ b/crates/nzb-web/src/sabnzbd_compat.rs @@ -378,6 +378,12 @@ fn dispatch_mode(state: &AppState, mode: &str, req: &SabApiRequest) -> Json handle_get_cats(state), + // RustNZB doesn't support post-processing scripts, so this is the + // permanent, correct response -- it matches what real SABnzbd + // reports when no script directory / scripts are configured + // (sabnzbd/api.py::_api_get_scripts -> filesystem.py::list_scripts). + "get_scripts" => Json(serde_json::json!({ "scripts": ["None"] })), + "change_cat" => handle_change_cat(state, req), "rename" => handle_rename(state, req), @@ -2148,4 +2154,17 @@ mod tests { sab_contract::golden(&contents); } } + + /// Real SABnzbd's `mode=get_scripts` always answers with at least + /// `["None"]` (sabnzbd/api.py::_api_get_scripts, + /// filesystem.py::list_scripts) -- clients that fetch categories and + /// scripts together to populate an "add download" dialog may fail to + /// populate the whole dialog if this call errors, as it previously did. + #[tokio::test] + async fn get_scripts_reports_none_when_unsupported() { + let test_state = test_state(); + let req = SabApiRequest::default(); + let response = dispatch_mode(&test_state.state, "get_scripts", &req).0; + assert_eq!(response["scripts"], serde_json::json!(["None"])); + } }