Simplify user update call syntax
This commit is contained in:
@ -56,11 +56,8 @@ pub struct AddSuccessful2FALogin(pub UserID, pub IpAddr);
|
||||
#[rtype(result = "bool")]
|
||||
pub struct Clear2FALoginHistory(pub UserID);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UpdateUserResult(pub bool);
|
||||
|
||||
#[derive(Message)]
|
||||
#[rtype(UpdateUserResult)]
|
||||
#[rtype(result = "bool")]
|
||||
pub struct UpdateUserRequest(pub User);
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -157,16 +154,16 @@ impl Handler<GetAllUsersRequest> for UsersActor {
|
||||
}
|
||||
|
||||
impl Handler<UpdateUserRequest> for UsersActor {
|
||||
type Result = MessageResult<UpdateUserRequest>;
|
||||
type Result = <UpdateUserRequest as actix::Message>::Result;
|
||||
|
||||
fn handle(&mut self, msg: UpdateUserRequest, _ctx: &mut Self::Context) -> Self::Result {
|
||||
MessageResult(UpdateUserResult(match self.manager.update_or_push(msg.0) {
|
||||
match self.manager.update_or_push(msg.0) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
log::error!("Failed to update user information! {:?}", e);
|
||||
false
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user