Adds update confirmation check

Signed-off-by: Ash Svitan <selfsigned-ash@proton.me>
This commit is contained in:
2026-04-30 20:49:07 +02:00
parent 15dd1722d4
commit cad0caf379
2 changed files with 40 additions and 28 deletions
+11 -8
View File
@@ -18,11 +18,9 @@ pub struct Item {
pub struct LoginItem {
pub id: String,
pub name: String,
pub user: Option<String>,
pub user: String,
pub password: String,
pub uris: Option<Vec<String>>,
#[serde(rename = "type")]
pub type_: String,
pub uris: Vec<String>,
}
pub fn check_rbw() -> Result<(), Error> {
@@ -59,7 +57,7 @@ pub fn get_items() -> Result<Vec<Item>, Error> {
pub fn get_logins(items: Vec<Item>) -> Result<Vec<LoginItem>, Error> {
let items = items
.iter()
.filter(|item| item.type_ == "Login")
.filter(|item| item.type_.to_lowercase() == "login")
.collect::<Vec<&Item>>();
let mut login_items = Vec::<LoginItem>::new();
@@ -72,13 +70,18 @@ pub fn get_logins(items: Vec<Item>) -> Result<Vec<LoginItem>, Error> {
login_items.push(LoginItem {
id: item.id.clone(),
name: item.name.clone(),
user: item.user.clone(),
user: match item.user.clone() {
Some(val) => val,
None => "".to_string(),
},
password: match password.strip_suffix("\n") {
Some(s) => s.to_string(),
None => password,
},
uris: item.uris.clone(),
type_: item.type_.clone(),
uris: match item.uris.clone() {
Some(val) => val,
None => Vec::new(),
},
});
}