aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2024-02-14 22:58:09 +0100
committerGitHub <noreply@github.com>2024-02-14 22:58:09 +0100
commit573d8c90e5de42c310c757aebcc6668800ca4396 (patch)
treee9f9e81290c6f22506f66436a7c4c9236afcd917 /src-tauri/src
parentd45f09613e07c2de04dd3938a37e07c560380e6a (diff)
downloadFlightCore-573d8c90e5de42c310c757aebcc6668800ca4396.tar.gz
FlightCore-573d8c90e5de42c310c757aebcc6668800ca4396.zip
refactor: Move release note announcement generation (#813)
to module dedicated for logic interacting with GitHub
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/github/release_notes.rs75
-rw-r--r--src-tauri/src/main.rs2
-rw-r--r--src-tauri/src/util.rs75
3 files changed, 76 insertions, 76 deletions
diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs
index 0dd4b948..8858c3d5 100644
--- a/src-tauri/src/github/release_notes.rs
+++ b/src-tauri/src/github/release_notes.rs
@@ -124,3 +124,78 @@ pub async fn get_northstar_release_notes() -> Result<Vec<ReleaseInfo>, String> {
Ok(release_info_vector)
}
+
+/// Checks latest GitHub release and generates a announcement message for Discord based on it
+#[tauri::command]
+pub async fn generate_release_note_announcement() -> Result<String, String> {
+ let octocrab = octocrab::instance();
+ let page = octocrab
+ .repos("R2Northstar", "Northstar")
+ .releases()
+ .list()
+ // Optional Parameters
+ .per_page(1)
+ .page(1u32)
+ // Send the request
+ .send()
+ .await
+ .unwrap();
+
+ // Get newest element
+ let latest_release_item = &page.items[0];
+
+ // Extract the URL to the GitHub release note
+ let github_release_link = latest_release_item.html_url.clone();
+
+ // Extract release version number
+ let current_ns_version = &latest_release_item.tag_name;
+
+ // Extract changelog and format it
+ let changelog = remove_markdown_links::remove_markdown_links(
+ latest_release_item
+ .body
+ .as_ref()
+ .unwrap()
+ .split("**Contributors:**")
+ .next()
+ .unwrap()
+ .trim(),
+ );
+
+ // Strings to insert for different sections
+ // Hardcoded for now
+ let general_info = "REPLACE ME";
+ let modders_info = "Mod compatibility should not be impacted";
+ let server_hosters_info = "REPLACE ME";
+
+ // Build announcement string
+ let return_string = format!(
+ r"Hello beautiful people <3
+**Northstar `{current_ns_version}` is out!**
+
+{general_info}
+
+**__Modders:__**
+
+{modders_info}
+
+**__Server hosters:__**
+
+{server_hosters_info}
+
+**__Changelog:__**
+```
+{changelog}
+```
+{github_release_link}
+
+Checkout #installation on how to install/update Northstar
+(the process is the same for both, using a Northstar installer like FlightCore, Viper, or VTOL is recommended over manual installation)
+
+If you do notice any bugs, please open an issue on Github or drop a message in the thread below
+"
+ );
+
+ // Return built announcement message
+ Ok(return_string.to_string())
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 60e5a3ed..0654d626 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -124,6 +124,7 @@ fn main() {
github::pull_requests::get_launcher_download_link,
github::pull_requests::get_pull_requests_wrapper,
github::release_notes::check_is_flightcore_outdated,
+ github::release_notes::generate_release_note_announcement,
github::release_notes::get_newest_flightcore_version,
github::release_notes::get_northstar_release_notes,
mod_management::delete_northstar_mod,
@@ -155,7 +156,6 @@ fn main() {
thunderstore::query_thunderstore_packages_api,
util::close_application,
util::force_panic,
- util::generate_release_note_announcement,
util::get_flightcore_version_number,
util::get_server_player_count,
util::is_debug_mode,
diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs
index b358b32b..ad09eec2 100644
--- a/src-tauri/src/util.rs
+++ b/src-tauri/src/util.rs
@@ -265,81 +265,6 @@ pub fn convert_release_candidate_number(version_number: String) -> String {
panic!();
}
-/// Checks latest GitHub release and generates a announcement message for Discord based on it
-#[tauri::command]
-pub async fn generate_release_note_announcement() -> Result<String, String> {
- let octocrab = octocrab::instance();
- let page = octocrab
- .repos("R2Northstar", "Northstar")
- .releases()
- .list()
- // Optional Parameters
- .per_page(1)
- .page(1u32)
- // Send the request
- .send()
- .await
- .unwrap();
-
- // Get newest element
- let latest_release_item = &page.items[0];
-
- // Extract the URL to the GitHub release note
- let github_release_link = latest_release_item.html_url.clone();
-
- // Extract release version number
- let current_ns_version = &latest_release_item.tag_name;
-
- // Extract changelog and format it
- let changelog = remove_markdown_links::remove_markdown_links(
- latest_release_item
- .body
- .as_ref()
- .unwrap()
- .split("**Contributors:**")
- .next()
- .unwrap()
- .trim(),
- );
-
- // Strings to insert for different sections
- // Hardcoded for now
- let general_info = "REPLACE ME";
- let modders_info = "Mod compatibility should not be impacted";
- let server_hosters_info = "REPLACE ME";
-
- // Build announcement string
- let return_string = format!(
- r"Hello beautiful people <3
-**Northstar `{current_ns_version}` is out!**
-
-{general_info}
-
-**__Modders:__**
-
-{modders_info}
-
-**__Server hosters:__**
-
-{server_hosters_info}
-
-**__Changelog:__**
-```
-{changelog}
-```
-{github_release_link}
-
-Checkout #installation on how to install/update Northstar
-(the process is the same for both, using a Northstar installer like FlightCore, Viper, or VTOL is recommended over manual installation)
-
-If you do notice any bugs, please open an issue on Github or drop a message in the thread below
-"
- );
-
- // Return built announcement message
- Ok(return_string.to_string())
-}
-
#[cfg(test)]
mod tests {
use super::*;