From: Dessalines Date: Wed, 16 Sep 2020 13:29:51 +0000 (-0500) Subject: Adding site checking. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/save/%22%7B%7D/static/gitweb.css?a=commitdiff_plain;h=3fbc8b130d86542efb0b6007b7e4a95428ed8c8d;p=lemmy.git Adding site checking. --- diff --git a/src/api/site.rs b/src/api/site.rs index 285c5756..4d6438a1 100644 --- a/src/api/site.rs +++ b/src/api/site.rs @@ -142,10 +142,9 @@ impl Perform for CreateSite { ) -> Result { let data: &CreateSite = &self; - match blocking(context.pool(), move |conn| { Site::read(conn, 1)}).await? - { - Ok(_site) => return Err(APIError::err("site_already_exists").into()), - Err(_e) => (), + let read_site = move |conn: &'_ _| Site::read(conn, 1); + if blocking(context.pool(), read_site).await?.is_ok() { + return Err(APIError::err("site_already_exists").into()); }; let user = get_user_from_jwt(&data.auth, context.pool()).await?;