Adding site checking.

pull/1141/head
Dessalines 2020-09-16 08:29:51 -05:00
parent dd93ac49a3
commit 3fbc8b130d
1 changed files with 3 additions and 4 deletions

View File

@ -142,10 +142,9 @@ impl Perform for CreateSite {
) -> Result<SiteResponse, LemmyError> { ) -> Result<SiteResponse, LemmyError> {
let data: &CreateSite = &self; let data: &CreateSite = &self;
match blocking(context.pool(), move |conn| { Site::read(conn, 1)}).await? let read_site = move |conn: &'_ _| Site::read(conn, 1);
{ if blocking(context.pool(), read_site).await?.is_ok() {
Ok(_site) => return Err(APIError::err("site_already_exists").into()), return Err(APIError::err("site_already_exists").into());
Err(_e) => (),
}; };
let user = get_user_from_jwt(&data.auth, context.pool()).await?; let user = get_user_from_jwt(&data.auth, context.pool()).await?;