mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-23 09:55:57 +03:00
feat: define interface for updating captcha metadata
This commit is contained in:
parent
c458e4a233
commit
1e6a259d57
2 changed files with 13 additions and 0 deletions
|
@ -137,6 +137,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||
/// create new captcha
|
||||
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
|
||||
async fn add_captcha_levels(
|
||||
&self,
|
||||
|
|
|
@ -142,6 +142,12 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
// delete captcha levels
|
||||
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
|
||||
db.delete_captcha(p.username, c.key).await.unwrap();
|
||||
assert!(!db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
||||
|
|
Loading…
Reference in a new issue