captcha stats

This commit is contained in:
realaravinth
2021-05-27 14:47:29 +05:30
parent df89938f2a
commit fcdbe66b26
28 changed files with 412 additions and 122 deletions

View File

@@ -22,10 +22,10 @@ use m_captcha::{
};
use serde::{Deserialize, Serialize};
use super::record_fetch;
use super::GetDurationResp;
use super::I32Levels;
use crate::errors::*;
use crate::stats::record::record_fetch;
use crate::Data;
use crate::V1_API_ROUTES;
@@ -43,7 +43,9 @@ pub struct GetConfigPayload {
// API keys are mcaptcha actor names
/// get PoW configuration for an mcaptcha key
#[my_codegen::post(path = "V1_API_ROUTES.pow.get_config.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()")]
#[my_codegen::post(
path = "V1_API_ROUTES.pow.get_config.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()"
)]
pub async fn get_config(
payload: web::Json<GetConfigPayload>,
data: web::Data<Data>,
@@ -82,7 +84,6 @@ pub async fn get_config(
Some(false) => Err(ServiceError::TokenNotFound),
None => Err(ServiceError::TokenNotFound),
}
}
/// Call this when [MCaptcha][m_captcha::MCaptcha] is not in master.
///

View File

@@ -24,7 +24,6 @@ pub mod verify_token;
pub use super::mcaptcha::duration::GetDurationResp;
pub use super::mcaptcha::levels::I32Levels;
use crate::api::v1::mcaptcha::stats::*;
pub fn services(cfg: &mut web::ServiceConfig) {
let cors = actix_cors::Cors::default()

View File

@@ -20,8 +20,8 @@ use actix_web::{web, HttpResponse, Responder};
use m_captcha::pow::Work;
use serde::{Deserialize, Serialize};
use super::record_solve;
use crate::errors::*;
use crate::stats::record::record_solve;
use crate::Data;
use crate::V1_API_ROUTES;
@@ -36,7 +36,9 @@ pub struct ValidationToken {
/// route handler that verifies PoW and issues a solution token
/// if verification is successful
#[my_codegen::post(path = "V1_API_ROUTES.pow.verify_pow.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()")]
#[my_codegen::post(
path = "V1_API_ROUTES.pow.verify_pow.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()"
)]
pub async fn verify_pow(
payload: web::Json<Work>,
data: web::Data<Data>,

View File

@@ -20,8 +20,8 @@ use actix_web::{web, HttpResponse, Responder};
use m_captcha::cache::messages::VerifyCaptchaResult;
use serde::{Deserialize, Serialize};
use super::record_confirm;
use crate::errors::*;
use crate::stats::record::record_confirm;
use crate::Data;
use crate::V1_API_ROUTES;
@@ -33,7 +33,9 @@ pub struct CaptchaValidateResp {
// API keys are mcaptcha actor names
/// route hander that validates a PoW solution token
#[my_codegen::post(path = "V1_API_ROUTES.pow.validate_captcha_token.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()")]
#[my_codegen::post(
path = "V1_API_ROUTES.pow.validate_captcha_token.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()"
)]
pub async fn validate_captcha_token(
payload: web::Json<VerifyCaptchaResult>,
data: web::Data<Data>,