feat: define get captcha cooldown period interface

This commit is contained in:
realaravinth 2022-05-14 16:27:15 +05:30
parent 9d7bb3c0be
commit 09a8591cb4
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
2 changed files with 6 additions and 0 deletions

View file

@ -183,6 +183,9 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
username: Option<&str>,
captcha_key: &str,
) -> DBResult<Vec<Level>>;
/// Get captcha's cooldown period
async fn get_captcha_cooldown(&self, captcha_key: &str) -> DBResult<i32>;
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]

View file

@ -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();