From c32c65d367aecec1e3261eae1b52bef8640db643 Mon Sep 17 00:00:00 2001 From: janost Date: Tue, 23 Oct 2018 00:32:43 +0200 Subject: [PATCH] Accept PUT and POST on /settings/domains, returns JsonResult, fixes saving Custom Equivalent Domains --- src/api/core/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index f8f65000..205bd5b2 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -121,6 +121,7 @@ pub fn routes() -> Vec { get_eq_domains, post_eq_domains, + put_eq_domains, ] } @@ -216,7 +217,7 @@ struct EquivDomainData { } #[post("/settings/domains", data = "")] -fn post_eq_domains(data: JsonUpcase, headers: Headers, conn: DbConn) -> EmptyResult { +fn post_eq_domains(data: JsonUpcase, headers: Headers, conn: DbConn) -> JsonResult { let data: EquivDomainData = data.into_inner().data; let excluded_globals = data.ExcludedGlobalEquivalentDomains.unwrap_or_default(); @@ -229,8 +230,13 @@ fn post_eq_domains(data: JsonUpcase, headers: Headers, conn: Db user.equivalent_domains = to_string(&equivalent_domains).unwrap_or("[]".to_string()); match user.save(&conn) { - Ok(()) => Ok(()), + Ok(()) => Ok(Json(json!({}))), Err(_) => err!("Failed to save user") } } + +#[put("/settings/domains", data = "")] +fn put_eq_domains(data: JsonUpcase, headers: Headers, conn: DbConn) -> JsonResult { + post_eq_domains(data, headers, conn) +}