mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-05-19 21:36:39 +00:00
address clippy lints
This commit is contained in:
parent
e3ff7278a9
commit
fe1fc3fb20
@ -113,10 +113,7 @@ async fn create(
|
|||||||
description: payload.description,
|
description: payload.description,
|
||||||
};
|
};
|
||||||
|
|
||||||
let broke_my_site_traffic = match payload.broke_my_site_traffic {
|
let broke_my_site_traffic = payload.broke_my_site_traffic.map(|n| n as i32);
|
||||||
Some(n) => Some(n as i32),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mcaptcha_config = create_runner(&msg, &data, &username).await?;
|
let mcaptcha_config = create_runner(&msg, &data, &username).await?;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
@ -191,10 +188,7 @@ async fn update(
|
|||||||
.execute(&data.db)
|
.execute(&data.db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let broke_my_site_traffic = match payload.pattern.broke_my_site_traffic {
|
let broke_my_site_traffic = payload.pattern.broke_my_site_traffic.map(|n| n as i32);
|
||||||
Some(n) => Some(n as i32),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic (
|
"INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic (
|
||||||
|
@ -166,6 +166,7 @@ impl Data {
|
|||||||
let creds = Self::get_creds();
|
let creds = Self::get_creds();
|
||||||
let c = creds.clone();
|
let c = creds.clone();
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
let init = thread::spawn(move || {
|
let init = thread::spawn(move || {
|
||||||
log::info!("Initializing credential manager");
|
log::info!("Initializing credential manager");
|
||||||
c.init();
|
c.init();
|
||||||
|
16
src/demo.rs
16
src/demo.rs
@ -34,19 +34,13 @@ pub const DEMO_USER: &str = "aaronsw";
|
|||||||
pub const DEMO_PASSWORD: &str = "password";
|
pub const DEMO_PASSWORD: &str = "password";
|
||||||
|
|
||||||
pub struct DemoUser {
|
pub struct DemoUser {
|
||||||
data: AppData,
|
|
||||||
duration: Duration,
|
|
||||||
handle: JoinHandle<()>,
|
handle: JoinHandle<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DemoUser {
|
impl DemoUser {
|
||||||
pub async fn spawn(data: AppData, duration: Duration) -> ServiceResult<Self> {
|
pub async fn spawn(data: AppData, duration: Duration) -> ServiceResult<Self> {
|
||||||
let handle = Self::run(data.clone(), duration.clone()).await?;
|
let handle = Self::run(data, duration).await?;
|
||||||
let d = Self {
|
let d = Self { handle };
|
||||||
data,
|
|
||||||
duration,
|
|
||||||
handle,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(d)
|
Ok(d)
|
||||||
}
|
}
|
||||||
@ -62,7 +56,7 @@ impl DemoUser {
|
|||||||
val: DEMO_USER.into(),
|
val: DEMO_USER.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !username_exists(&user_exists_payload, &data).await?.exists {
|
if !username_exists(&user_exists_payload, data).await?.exists {
|
||||||
let register_payload = Register {
|
let register_payload = Register {
|
||||||
username: DEMO_USER.into(),
|
username: DEMO_USER.into(),
|
||||||
password: DEMO_PASSWORD.into(),
|
password: DEMO_PASSWORD.into(),
|
||||||
@ -71,7 +65,7 @@ impl DemoUser {
|
|||||||
};
|
};
|
||||||
|
|
||||||
log::info!("Registering demo user");
|
log::info!("Registering demo user");
|
||||||
match register_runner(®ister_payload, &data).await {
|
match register_runner(®ister_payload, data).await {
|
||||||
Err(ServiceError::UsernameTaken) | Ok(_) => Ok(()),
|
Err(ServiceError::UsernameTaken) | Ok(_) => Ok(()),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
@ -82,7 +76,7 @@ impl DemoUser {
|
|||||||
|
|
||||||
async fn delete_demo_user(data: &AppData) -> ServiceResult<()> {
|
async fn delete_demo_user(data: &AppData) -> ServiceResult<()> {
|
||||||
log::info!("Deleting demo user");
|
log::info!("Deleting demo user");
|
||||||
delete_user(DEMO_USER, &data).await?;
|
delete_user(DEMO_USER, data).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,6 @@ impl ResponseError for ServiceError {
|
|||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user