mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-12 02:25:41 +00:00
rm actor temp
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{post, web, HttpResponse, Responder};
|
||||
use awc::Client;
|
||||
use actix_web::{client::Client, post, web, HttpResponse, Responder};
|
||||
//use awc::Client;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
@@ -163,6 +163,8 @@ pub async fn delete_domain(
|
||||
)
|
||||
.execute(&data.db)
|
||||
.await?;
|
||||
// TODO check running actors and delete
|
||||
// if domain(api_key) matches mcaptcha actor id
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
||||
|
||||
@@ -246,7 +248,6 @@ mod tests {
|
||||
#[actix_rt::test]
|
||||
async fn domain_verification_works() {
|
||||
use crate::api::v1::tests::*;
|
||||
use awc::Client;
|
||||
use std::sync::mpsc;
|
||||
use std::thread;
|
||||
|
||||
@@ -264,7 +265,7 @@ mod tests {
|
||||
|
||||
let (tx, rx) = mpsc::channel();
|
||||
thread::spawn(move || {
|
||||
rt::System::new("").block_on(server(IP, tx));
|
||||
actix_rt::System::new("").block_on(server(IP, tx));
|
||||
});
|
||||
let srv = rx.recv().unwrap();
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ pub mod domains;
|
||||
pub mod duration;
|
||||
pub mod levels;
|
||||
pub mod mcaptcha;
|
||||
pub mod pow;
|
||||
|
||||
pub use super::auth::is_authenticated;
|
||||
|
||||
|
||||
59
src/api/v1/mcaptcha/pow.rs
Normal file
59
src/api/v1/mcaptcha/pow.rs
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{post, web, HttpResponse, Responder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{get_random, is_authenticated};
|
||||
use crate::errors::*;
|
||||
use crate::Data;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct PoWConfig {
|
||||
pub name: String,
|
||||
pub domain: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct GetConfigPayload {
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
// API keys are mcaptcha actor names
|
||||
|
||||
#[post("/api/v1/mcaptcha/pow/config")]
|
||||
pub async fn get_config(
|
||||
payload: web::Json<GetConfigPayload>,
|
||||
data: web::Data<Data>,
|
||||
id: Identity,
|
||||
) -> ServiceResult<impl Responder> {
|
||||
is_authenticated(&id)?;
|
||||
|
||||
let res = sqlx::query!(
|
||||
"SELECT EXISTS (SELECT 1 from mcaptcha_config WHERE key = $1)",
|
||||
&payload.key,
|
||||
)
|
||||
.fetch_one(&data.db)
|
||||
.await?;
|
||||
|
||||
if let Some(x) = res.exists {
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
||||
@@ -51,6 +51,9 @@ pub fn services(cfg: &mut ServiceConfig) {
|
||||
cfg.service(mcaptcha::duration::update_duration);
|
||||
cfg.service(mcaptcha::duration::get_duration);
|
||||
|
||||
// pow
|
||||
cfg.service(mcaptcha::pow::get_config);
|
||||
|
||||
// meta
|
||||
cfg.service(meta::build_details);
|
||||
cfg.service(meta::health);
|
||||
|
||||
Reference in New Issue
Block a user