Merge pull request #3872 from Grelo4ka/cli-msgbox

Use match statement in msgbox function
This commit is contained in:
RustDesk 2023-04-01 09:54:55 +08:00 committed by GitHub
commit 2632ed98a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,18 +48,24 @@ impl Interface for Session {
}
fn msgbox(&self, msgtype: &str, title: &str, text: &str, link: &str) {
if msgtype == "input-password" {
self.sender
.send(Data::Login((self.password.clone(), true)))
.ok();
} else if msgtype == "re-input-password" {
log::error!("{}: {}", title, text);
let pass = rpassword::prompt_password("Enter password: ").unwrap();
self.sender.send(Data::Login((pass, true))).ok();
} else if msgtype.contains("error") {
log::error!("{}: {}: {}", msgtype, title, text);
} else {
log::info!("{}: {}: {}", msgtype, title, text);
match msgtype {
"input-password" => {
self.sender
.send(Data::Login((self.password.clone(), true)))
.ok();
}
"re-input-password" => {
log::error!("{}: {}", title, text);
let password = rpassword::prompt_password("Enter password: ").unwrap();
let login_data = Data::Login((password, true));
self.sender.send(login_data).ok();
}
msg if msg.contains("error") => {
log::error!("{}: {}: {}", msgtype, title, text);
}
_ => {
log::info!("{}: {}: {}", msgtype, title, text);
}
}
}