Simplify user update call syntax

This commit is contained in:
2022-11-19 16:43:28 +01:00
parent b10c48d080
commit 0c35400e64
3 changed files with 8 additions and 15 deletions

View File

@ -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
}
}))
}
}
}