mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
feat: define interface for updating captcha metadata
This commit is contained in:
@@ -137,6 +137,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||||||
/// create new captcha
|
/// create new captcha
|
||||||
async fn create_captcha(&self, username: &str, p: &CreateCaptcha) -> DBResult<()>;
|
async fn create_captcha(&self, username: &str, p: &CreateCaptcha) -> DBResult<()>;
|
||||||
|
|
||||||
|
/// update captcha metadata; doesn't change captcha key
|
||||||
|
async fn update_captcha_metadata(
|
||||||
|
&self,
|
||||||
|
username: &str,
|
||||||
|
p: &CreateCaptcha,
|
||||||
|
) -> DBResult<()>;
|
||||||
|
|
||||||
/// Add levels to captcha
|
/// Add levels to captcha
|
||||||
async fn add_captcha_levels(
|
async fn add_captcha_levels(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -142,6 +142,12 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
// delete captcha levels
|
// delete captcha levels
|
||||||
db.delete_captcha_levels(p.username, c.key).await.unwrap();
|
db.delete_captcha_levels(p.username, c.key).await.unwrap();
|
||||||
|
|
||||||
|
// update captcha; set description = username and duration *= duration;
|
||||||
|
let mut c2 = c.clone();
|
||||||
|
c2.duration *= c2.duration;
|
||||||
|
c2.description = p.username;
|
||||||
|
db.update_captcha_metadata(p.username, &c2).await.unwrap();
|
||||||
|
|
||||||
// delete captcha
|
// delete captcha
|
||||||
db.delete_captcha(p.username, c.key).await.unwrap();
|
db.delete_captcha(p.username, c.key).await.unwrap();
|
||||||
assert!(!db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
assert!(!db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
||||||
|
|||||||
Reference in New Issue
Block a user