From 09a8591cb417efd5e80ccebf749e35b1cb057671 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 14 May 2022 16:27:15 +0530 Subject: [PATCH] feat: define get captcha cooldown period interface --- db/db-core/src/lib.rs | 3 +++ db/db-core/src/tests.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index aa5f2a3d..2932dc4a 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -183,6 +183,9 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { username: Option<&str>, captcha_key: &str, ) -> DBResult>; + + /// Get captcha's cooldown period + async fn get_captcha_cooldown(&self, captcha_key: &str) -> DBResult; } #[derive(Clone, Debug, Default, Deserialize, Serialize)] diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index e07f9352..8637fe90 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -136,6 +136,9 @@ pub async fn database_works<'a, T: MCDatabase>( assert!(db.captcha_exists(None, c.key).await.unwrap()); assert!(db.captcha_exists(Some(p.username), c.key).await.unwrap()); + // get captcha cooldown duration + assert_eq!(db.get_captcha_cooldown(c.key).await.unwrap(), c.duration); + // add captcha levels db.add_captcha_levels(p.username, c.key, l).await.unwrap();