Adding site checking.

This commit is contained in:
Dessalines 2020-09-16 08:29:51 -05:00
parent dd93ac49a3
commit 3fbc8b130d

View File

@ -142,10 +142,9 @@ impl Perform for CreateSite {
) -> Result<SiteResponse, LemmyError> {
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?;