mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
feat: migrate get_levels to use db_*
This commit is contained in:
@@ -19,6 +19,7 @@ use actix_web::{http, web, HttpResponse, Responder};
|
|||||||
use sailfish::TemplateOnce;
|
use sailfish::TemplateOnce;
|
||||||
|
|
||||||
use db_core::errors::DBError;
|
use db_core::errors::DBError;
|
||||||
|
use libmcaptcha::defense::Level;
|
||||||
|
|
||||||
use crate::api::v1::mcaptcha::easy::TrafficPatternRequest;
|
use crate::api::v1::mcaptcha::easy::TrafficPatternRequest;
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
@@ -33,11 +34,11 @@ struct McaptchaConfig {
|
|||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
//#[derive(Clone)]
|
||||||
struct Level {
|
//struct Level {
|
||||||
difficulty_factor: i32,
|
// difficulty_factor: i32,
|
||||||
visitor_threshold: i32,
|
// visitor_threshold: i32,
|
||||||
}
|
//}
|
||||||
|
|
||||||
#[derive(TemplateOnce, Clone)]
|
#[derive(TemplateOnce, Clone)]
|
||||||
#[template(path = "panel/sitekey/edit/advance.html")]
|
#[template(path = "panel/sitekey/edit/advance.html")]
|
||||||
@@ -83,17 +84,7 @@ pub async fn advance(
|
|||||||
.fetch_one(&data.db)
|
.fetch_one(&data.db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let levels = sqlx::query_as!(
|
let levels = data.dblib.get_captcha_levels(Some(&username), &key).await?;
|
||||||
Level,
|
|
||||||
"SELECT
|
|
||||||
difficulty_factor, visitor_threshold
|
|
||||||
FROM
|
|
||||||
mcaptcha_levels
|
|
||||||
WHERE config_id = $1 ORDER BY difficulty_factor ASC",
|
|
||||||
&config.config_id
|
|
||||||
)
|
|
||||||
.fetch_all(&data.db)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let body = AdvanceEditPage::new(config, levels, key)
|
let body = AdvanceEditPage::new(config, levels, key)
|
||||||
.render_once()
|
.render_once()
|
||||||
|
|||||||
Reference in New Issue
Block a user