fix more settings routes

This commit is contained in:
tamo 2021-04-01 15:50:45 +02:00
parent 79c63049d7
commit 73973e2b9e
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
2 changed files with 7 additions and 3 deletions

View File

@ -27,7 +27,9 @@ macro_rules! make_setting_route {
..Default::default()
};
match data.update_settings(index_uid.into_inner(), settings, false).await {
Ok(update_status) => Ok(HttpResponse::Ok().json(update_status)),
Ok(update_status) => {
Ok(HttpResponse::Accepted().json(serde_json::json!({ "updateId": update_status.id() })))
}
Err(e) => {
Ok(HttpResponse::BadRequest().json(serde_json::json!({ "error": e.to_string() })))
}
@ -46,7 +48,9 @@ macro_rules! make_setting_route {
};
match data.update_settings(index_uid.into_inner(), settings, true).await {
Ok(update_status) => Ok(HttpResponse::Ok().json(update_status)),
Ok(update_status) => {
Ok(HttpResponse::Accepted().json(serde_json::json!({ "updateId": update_status.id() })))
}
Err(e) => {
Ok(HttpResponse::BadRequest().json(serde_json::json!({ "error": e.to_string() })))
}

View File

@ -142,7 +142,7 @@ macro_rules! test_setting_routes {
.map(|c| if c == '_' { '-' } else { c })
.collect::<String>());
let (response, code) = server.service.post(url, serde_json::Value::Null).await;
assert_eq!(code, 200, "{}", response);
assert_eq!(code, 202, "{}", response);
let (response, code) = server.index("test").get().await;
assert_eq!(code, 200, "{}", response);
}