addressing clippy lints

This commit is contained in:
realaravinth
2021-06-11 23:39:38 +05:30
parent ffdd1865bb
commit dcfba60c86
23 changed files with 124 additions and 109 deletions

View File

@@ -58,7 +58,7 @@ async fn delete_account(
}
}
Err(RowNotFound) => return Err(ServiceError::UsernameNotFound),
Err(_) => return Err(ServiceError::InternalServerError)?,
Err(_) => return Err(ServiceError::InternalServerError),
}
}

View File

@@ -74,14 +74,14 @@ async fn set_email(
)
.execute(&data.db)
.await;
if !res.is_ok() {
if res.is_err() {
if let Err(sqlx::Error::Database(err)) = res {
if err.code() == Some(Cow::from("23505"))
&& err.message().contains("mcaptcha_users_email_key")
{
Err(ServiceError::EmailTaken)?
return Err(ServiceError::EmailTaken);
} else {
Err(sqlx::Error::Database(err))?
return Err(sqlx::Error::Database(err).into());
}
};
}

View File

@@ -32,8 +32,8 @@ pub mod routes {
pub struct Account {
pub delete: &'static str,
pub email_exists: &'static str,
pub update_email: &'static str,
pub get_secret: &'static str,
pub update_email: &'static str,
pub update_secret: &'static str,
pub username_exists: &'static str,
}
@@ -47,12 +47,13 @@ pub mod routes {
let username_exists = "/api/v1/account/username/exists";
let update_email = "/api/v1/account/email/update";
Account {
get_secret,
update_secret,
username_exists,
update_email,
delete,
email_exists,
get_secret,
update_email,
update_secret,
username_exists,
}
}
}

View File

@@ -71,16 +71,14 @@ async fn update_user_secret(
.await;
if res.is_ok() {
break;
} else {
if let Err(sqlx::Error::Database(err)) = res {
if err.code() == Some(Cow::from("23505"))
&& err.message().contains("mcaptcha_users_secret_key")
{
continue;
} else {
Err(sqlx::Error::Database(err))?;
}
};
} else if let Err(sqlx::Error::Database(err)) = res {
if err.code() == Some(Cow::from("23505"))
&& err.message().contains("mcaptcha_users_secret_key")
{
continue;
} else {
return Err(sqlx::Error::Database(err).into());
}
}
}
Ok(HttpResponse::Ok())