feat: implement get captcha cooldown period interface for sqlx postgres

This commit is contained in:
realaravinth 2022-05-14 16:27:28 +05:30
parent 09a8591cb4
commit 7daffe767c
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88

View file

@ -513,6 +513,25 @@ impl MCDatabase for Database {
}
Ok(new_levels)
}
/// Get captcha's cooldown period
async fn get_captcha_cooldown(&self, captcha_key: &str) -> DBResult<i32> {
struct DurationResp {
duration: i32,
}
let resp = sqlx::query_as!(
DurationResp,
"SELECT duration FROM mcaptcha_config
WHERE key = $1",
captcha_key,
)
.fetch_one(&self.pool)
.await
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
Ok(resp.duration)
}
}
fn now_unix_time_stamp() -> i64 {