This commit is contained in:
Timon
2026-02-13 19:55:30 +00:00
parent 40b40f9239
commit 88eb489352
+14 -12
View File
@@ -1,21 +1,20 @@
const UPDATE_CHECK_URL: &str = "https://localhost:8080/v1/update"; const UPDATE_CHECK_URL: &str = "https://localhost:8080/v1/update";
async fn check_for_update(info: Info) -> Status { async fn check_for_update(info: Info) -> UpdateCheckRsponse {
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let response = client.post(UPDATE_CHECK_URL).json(&info).send().await; let response = client.post(UPDATE_CHECK_URL).json(&info).send().await;
match response { match response {
Ok(response) => { Ok(response) if response.status().is_success() => {
if response.status().is_success() { if let Ok(result) = response.json::<UpdateCheckRsponse>().await {
match response.json::<Status>().await { return result;
Ok(result) => result,
Err(_) => Status::Unknown,
}
} else {
Status::Unknown
} }
} }
Err(_) => Status::Unknown, _ => {}
}
UpdateCheckRsponse {
status: Status::Unknown,
messages: Vec::new(),
} }
} }
@@ -69,17 +68,20 @@ pub enum Source {
Other(String), Other(String),
} }
struct UpdateCheckRsponse { #[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct UpdateCheckRsponse {
status: Status, status: Status,
messages: Vec<Message>, messages: Vec<Message>,
} }
struct Message { #[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct Message {
title: String, title: String,
body: String, body: String,
action: Action, action: Action,
} }
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Action { pub enum Action {
OpenUrl(String), OpenUrl(String),
PerformAutoUpdate, PerformAutoUpdate,