mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-02-17 08:59:46 +03:00
chore: cleanup and addressing clippy lints
This commit is contained in:
parent
d7fd23f565
commit
629c841e2d
11 changed files with 14 additions and 45 deletions
|
@ -160,7 +160,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
db.create_notification(an).await.unwrap();
|
||||
|
||||
// 2. Get notifications
|
||||
let notifications = db.get_all_unread_notifications(&an.to).await.unwrap();
|
||||
let notifications = db.get_all_unread_notifications(an.to).await.unwrap();
|
||||
assert_eq!(notifications.len(), 2);
|
||||
assert_eq!(notifications[0].heading.as_ref().unwrap(), an.heading);
|
||||
|
||||
|
@ -168,7 +168,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
db.mark_notification_read(an.to, notifications[0].id.unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
let new_notifications = db.get_all_unread_notifications(&an.to).await.unwrap();
|
||||
let new_notifications = db.get_all_unread_notifications(an.to).await.unwrap();
|
||||
assert_eq!(new_notifications.len(), 1);
|
||||
|
||||
// create captcha
|
||||
|
|
|
@ -59,7 +59,7 @@ async fn everyting_works() {
|
|||
},
|
||||
];
|
||||
|
||||
const add_notification: AddNotification = AddNotification {
|
||||
const ADD_NOTIFICATION: AddNotification = AddNotification {
|
||||
from: NAME,
|
||||
to: NAME,
|
||||
message: MESSAGE,
|
||||
|
@ -84,5 +84,5 @@ async fn everyting_works() {
|
|||
key: CAPTCHA_SECRET,
|
||||
description: CAPTCHA_DESCRIPTION,
|
||||
};
|
||||
database_works(&db, &p, &c, &LEVELS, &TRAFFIC_PATTERN, &add_notification).await;
|
||||
database_works(&db, &p, &c, &LEVELS, &TRAFFIC_PATTERN, &ADD_NOTIFICATION).await;
|
||||
}
|
||||
|
|
|
@ -63,9 +63,7 @@ async fn set_username(
|
|||
|
||||
let processed_uname = data.creds.username(&payload.username)?;
|
||||
|
||||
data.db
|
||||
.update_username(&username, &processed_uname)
|
||||
.await?;
|
||||
data.db.update_username(&username, &processed_uname).await?;
|
||||
|
||||
id.forget();
|
||||
id.remember(processed_uname);
|
||||
|
|
|
@ -166,9 +166,7 @@ async fn update(
|
|||
|
||||
update_captcha_runner(&msg, &data, &username).await?;
|
||||
|
||||
data.db
|
||||
.delete_traffic_pattern(&username, &msg.key)
|
||||
.await?;
|
||||
data.db.delete_traffic_pattern(&username, &msg.key).await?;
|
||||
|
||||
data.db
|
||||
.add_traffic_pattern(&username, &msg.key, &pattern)
|
||||
|
@ -196,7 +194,6 @@ pub mod tests {
|
|||
|
||||
#[test]
|
||||
fn easy_configuration_works() {
|
||||
const NAME: &str = "defaultuserconfgworks";
|
||||
let settings = crate::tests::get_settings();
|
||||
|
||||
let mut payload = TrafficPattern {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
use actix_identity::Identity;
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
|
||||
use libmcaptcha::defense::Level;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::create::MCaptchaDetails;
|
||||
|
|
|
@ -101,7 +101,7 @@ pub async fn get_config(
|
|||
async fn init_mcaptcha(data: &AppData, key: &str) -> ServiceResult<()> {
|
||||
// get levels
|
||||
let levels = data.db.get_captcha_levels(None, key).await?;
|
||||
let duration = data.db.get_captcha_cooldown(&key).await?;
|
||||
let duration = data.db.get_captcha_cooldown(key).await?;
|
||||
|
||||
// build defense
|
||||
let mut defense = DefenseBuilder::default();
|
||||
|
|
|
@ -185,7 +185,7 @@ impl Data {
|
|||
log::info!("Initialized credential manager");
|
||||
});
|
||||
|
||||
let pool = s.database.pool;
|
||||
let pool = s.database.pool;
|
||||
let pool_options = PgPoolOptions::new().max_connections(pool);
|
||||
let connection_options = ConnectionOptions::Fresh(Fresh {
|
||||
pool_options,
|
||||
|
|
|
@ -23,7 +23,6 @@ use sailfish::TemplateOnce;
|
|||
|
||||
use crate::errors::*;
|
||||
use crate::Data;
|
||||
use crate::SETTINGS;
|
||||
|
||||
const PAGE: &str = "Login";
|
||||
|
||||
|
|
|
@ -240,21 +240,6 @@ impl From<CaptchaError> for ServiceError {
|
|||
}
|
||||
}
|
||||
|
||||
//#[cfg(not(tarpaulin_include))]
|
||||
//impl From<sqlx::Error> for ServiceError {
|
||||
// #[cfg(not(tarpaulin_include))]
|
||||
// fn from(e: sqlx::Error) -> Self {
|
||||
// use sqlx::error::Error;
|
||||
// use std::borrow::Cow;
|
||||
// if let Error::Database(err) = e {
|
||||
// if err.code() == Some(Cow::from("23505")) {
|
||||
// return ServiceError::UsernameTaken;
|
||||
// }
|
||||
// }
|
||||
// ServiceError::InternalServerError
|
||||
// }
|
||||
//}
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
impl From<SmtpError> for ServiceError {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
|
@ -294,14 +279,6 @@ pub enum PageError {
|
|||
ServiceError(ServiceError),
|
||||
}
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
impl From<sqlx::Error> for PageError {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
fn from(_: sqlx::Error) -> Self {
|
||||
PageError::InternalServerError
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
impl From<ServiceError> for PageError {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
|
|
|
@ -20,7 +20,6 @@ use lazy_static::lazy_static;
|
|||
use my_codegen::get;
|
||||
use sailfish::TemplateOnce;
|
||||
|
||||
use crate::api::v1::RedirectQuery;
|
||||
use crate::PAGES;
|
||||
|
||||
#[derive(Clone, TemplateOnce)]
|
||||
|
|
12
src/stats.rs
12
src/stats.rs
|
@ -50,12 +50,12 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl Clone for Box<dyn CloneStats> {
|
||||
fn clone(&self) -> Self {
|
||||
self.clone()
|
||||
//(*self).clone_stats()
|
||||
}
|
||||
}
|
||||
//impl Clone for Box<dyn CloneStats> {
|
||||
// fn clone(&self) -> Self {
|
||||
// Box::clone(self)
|
||||
// //(*self).clone_stats()
|
||||
// }
|
||||
//}
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
|
||||
pub struct CaptchaStats {
|
||||
|
|
Loading…
Add table
Reference in a new issue