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

@@ -94,10 +94,10 @@ pub async fn add_mcaptcha_util(
{
continue;
} else {
Err(sqlx::Error::Database(err))?;
return Err(sqlx::Error::Database(err).into());
}
}
Err(e) => Err(e)?,
Err(e) => return Err(e.into()),
Ok(_) => {
resp = MCaptchaDetails {
@@ -128,15 +128,13 @@ async fn update_token(
let res = update_token_helper(&key, &payload.key, &username, &data).await;
if res.is_ok() {
break;
} else {
if let Err(sqlx::Error::Database(err)) = res {
if err.code() == Some(Cow::from("23505")) {
continue;
} else {
Err(sqlx::Error::Database(err))?;
}
};
}
} else if let Err(sqlx::Error::Database(err)) = res {
if err.code() == Some(Cow::from("23505")) {
continue;
} else {
return Err(sqlx::Error::Database(err).into());
}
};
}
let resp = MCaptchaDetails {

View File

@@ -19,7 +19,7 @@ use actix_identity::Identity;
use actix_web::{web, HttpResponse, Responder};
use serde::{Deserialize, Serialize};
use crate::api::v1::mcaptcha::mcaptcha::MCaptchaDetails;
use crate::api::v1::mcaptcha::captcha::MCaptchaDetails;
use crate::errors::*;
use crate::AppData;

View File

@@ -20,8 +20,8 @@ use libmcaptcha::{defense::Level, DefenseBuilder};
use log::debug;
use serde::{Deserialize, Serialize};
use super::mcaptcha::add_mcaptcha_util;
use crate::api::v1::mcaptcha::mcaptcha::MCaptchaDetails;
use super::captcha::add_mcaptcha_util;
use super::captcha::MCaptchaDetails;
use crate::errors::*;
use crate::AppData;
@@ -29,9 +29,9 @@ pub mod routes {
pub struct Levels {
pub add: &'static str,
pub update: &'static str,
pub delete: &'static str,
pub get: &'static str,
pub update: &'static str,
}
impl Levels {
@@ -42,9 +42,9 @@ pub mod routes {
let get = "/api/v1/mcaptcha/levels/get";
Levels {
add,
delete,
get,
update,
delete,
}
}
}
@@ -76,7 +76,7 @@ async fn add_levels(
let username = id.identity().unwrap();
for level in payload.levels.iter() {
defense.add_level(level.clone())?;
defense.add_level(*level)?;
}
defense.build()?;
@@ -132,7 +132,7 @@ async fn update_levels(
let mut defense = DefenseBuilder::default();
for level in payload.levels.iter() {
defense.add_level(level.clone())?;
defense.add_level(*level)?;
}
// I feel this is necessary as both difficulty factor _and_ visitor threshold of a

View File

@@ -15,9 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
pub mod captcha;
pub mod duration;
pub mod levels;
pub mod mcaptcha;
pub fn get_random(len: usize) -> String {
use std::iter;
@@ -36,5 +36,5 @@ pub fn get_random(len: usize) -> String {
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
duration::services(cfg);
levels::services(cfg);
mcaptcha::services(cfg);
captcha::services(cfg);
}