feat: advance siteey create now allows setting publication status

This commit is contained in:
Aravinth Manivannan
2023-06-30 16:49:35 +05:30
parent 22edb04ce2
commit 468752f691
6 changed files with 28 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ pub struct CreateCaptcha {
pub levels: Vec<Level>,
pub duration: u32,
pub description: String,
pub publish_benchmarks: bool,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -52,6 +53,11 @@ pub async fn create(
) -> ServiceResult<impl Responder> {
let username = id.identity().unwrap();
let mcaptcha_config = runner::create(&payload, &data, &username).await?;
if payload.publish_benchmarks {
data.db
.analytics_create_psuedo_id_if_not_exists(&mcaptcha_config.key)
.await?;
}
Ok(HttpResponse::Ok().json(mcaptcha_config))
}

View File

@@ -82,6 +82,7 @@ pub async fn level_routes_work(data: ArcData) {
levels: levels.clone(),
description: add_level.description,
duration: add_level.duration,
publish_benchmarks: true,
};
let add_token_resp = test::call_service(

View File

@@ -250,6 +250,7 @@ pub mod tests {
levels: levels.into(),
duration: 30,
description: "dummy".into(),
publish_benchmarks: true,
};
// 1. add level

View File

@@ -262,5 +262,6 @@ pub fn get_level_data() -> CreateCaptcha {
levels,
duration: 30,
description: "dummy".into(),
publish_benchmarks: false,
}
}