aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/github/release_notes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/github/release_notes.rs')
-rw-r--r--src-tauri/src/github/release_notes.rs38
1 files changed, 26 insertions, 12 deletions
diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs
index 16b65183..cbe3d0b1 100644
--- a/src-tauri/src/github/release_notes.rs
+++ b/src-tauri/src/github/release_notes.rs
@@ -98,19 +98,33 @@ pub async fn check_is_flightcore_outdated() -> Result<bool, String> {
#[tauri::command]
pub async fn get_northstar_release_notes() -> Result<Vec<ReleaseInfo>, String> {
- let url = "https://api.github.com/repos/R2Northstar/Northstar/releases";
- let res = match fetch_github_releases_api(url).await {
- Ok(res) => res,
- Err(err) => return Err(format!("Failed getting Northstar release notes: {err}")),
- };
+ let octocrab = octocrab::instance();
+ let page = octocrab
+ .repos("R2Northstar", "Northstar")
+ .releases()
+ .list()
+ // Optional Parameters
+ .per_page(25)
+ .page(1u32)
+ // Send the request
+ .send()
+ .await
+ .unwrap();
+
+ // TODO there's probably a way to automatically serialize into the struct but I don't know yet how to
+ let mut release_info_vector: Vec<ReleaseInfo> = vec![];
+ for item in page.items {
+ let release_info = ReleaseInfo {
+ name: item.name.ok_or(String::from("Release name not found"))?,
+ published_at: item
+ .published_at
+ .ok_or(String::from("Release date not found"))?
+ .to_rfc3339(),
+ body: item.body.ok_or(String::from("Release body not found"))?,
+ };
+ release_info_vector.push(release_info);
+ }
- let release_info_vector: Vec<ReleaseInfo> = match serde_json::from_str(&res) {
- Ok(res) => res,
- Err(err) => {
- log::warn!("{err}");
- return Err("Could not fetch release notes. JSON was not well-formatted".to_string());
- }
- };
log::info!("Done checking GitHub API");
Ok(release_info_vector)