mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-27 03:48:52 +03:00
update levels in cache when db is updated
This commit is contained in:
parent
b1fd56e9b6
commit
f7afc72d81
2 changed files with 19 additions and 17 deletions
|
@ -17,7 +17,7 @@
|
|||
use actix_identity::Identity;
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use futures::future::try_join_all;
|
||||
use libmcaptcha::{defense::Level, DefenseBuilder};
|
||||
use libmcaptcha::{defense::Level, DefenseBuilder, master::messages::RemoveCaptcha};
|
||||
use log::debug;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -190,6 +190,9 @@ async fn update_levels(
|
|||
}
|
||||
|
||||
try_join_all(futs).await?;
|
||||
if let Err(ServiceError::CaptchaError(e)) = data.captcha.remove(RemoveCaptcha(payload.key.clone())).await {
|
||||
log::error!("Deleting captcha key {} while updating it, error: {:?}", &payload.key, e)
|
||||
}
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
||||
|
||||
|
@ -277,7 +280,6 @@ mod tests {
|
|||
let app = get_app!(data).await;
|
||||
|
||||
// 2. get level
|
||||
|
||||
let add_level = get_level_data();
|
||||
let get_level_resp = test::call_service(
|
||||
&app,
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
use std::env;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
|
Loading…
Reference in a new issue