addvisitorresult::new takes mcaptcha

This commit is contained in:
Aravinth Manivannan 2021-06-08 18:21:32 +05:30
parent edcf55969c
commit c496b2c61b
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
3 changed files with 18 additions and 10 deletions

View file

@ -151,14 +151,14 @@ impl Handler<DeleteVisitor> for Counter {
#[rtype(result = "AddVisitorResult")] #[rtype(result = "AddVisitorResult")]
pub struct AddVisitor; pub struct AddVisitor;
impl AddVisitorResult { //impl AddVisitorResult {
fn new(m: &Counter) -> Self { // fn new(m: &Counter) -> Self {
AddVisitorResult { // AddVisitorResult {
duration: m.0.get_duration(), // duration: m.0.get_duration(),
difficulty_factor: m.0.get_difficulty(), // difficulty_factor: m.0.get_difficulty(),
} // }
} // }
} //}
impl Handler<AddVisitor> for Counter { impl Handler<AddVisitor> for Counter {
type Result = MessageResult<AddVisitor>; type Result = MessageResult<AddVisitor>;
@ -177,7 +177,7 @@ impl Handler<AddVisitor> for Counter {
ctx.spawn(wait_for); ctx.spawn(wait_for);
self.0.add_visitor(); self.0.add_visitor();
MessageResult(AddVisitorResult::new(&self)) MessageResult(AddVisitorResult::new(&self.0))
} }
} }

View file

@ -68,3 +68,12 @@ pub struct AddSite {
pub id: String, pub id: String,
pub mcaptcha: MCaptcha, pub mcaptcha: MCaptcha,
} }
impl AddVisitorResult {
fn new(m: &MCaptcha) -> Self {
AddVisitorResult {
duration: m.get_duration(),
difficulty_factor: m.get_difficulty(),
}
}
}

View file

@ -38,7 +38,6 @@ use crate::master::{AddSite, AddVisitor, Master as MasterTrait};
use super::connection::RedisConnection; use super::connection::RedisConnection;
#[derive(Clone)] #[derive(Clone)]
pub enum Redis { pub enum Redis {
Single(Client), Single(Client),