Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(app): bundle updater with new auth gateway (#6201)
Will Hutchinsonb70a9ece3850
diff --git a/apps/web/tauri/macro_bundle_updater_plugin/src/outbound/api_client.rs b/apps/web/tauri/macro_bundle_updater_plugin/src/outbound/api_client.rsindex f26c89d765..345fc8caa2 100644--- a/apps/web/tauri/macro_bundle_updater_plugin/src/outbound/api_client.rs+++ b/apps/web/tauri/macro_bundle_updater_plugin/src/outbound/api_client.rs@@ -9,6 +9,9 @@ use thiserror::Error;use tokio::io::AsyncWriteExt;use url::Url;+#[cfg(test)]+mod test;+/// HTTP client for checking and downloading bundle updates.pub struct BundleClient {/// Reusable HTTP client.@@ -31,24 +34,19 @@ pub enum BundleClientErr {impl BundleClient {/// Create a new client pointing at the given base URL.pub fn new(mut base: Url) -> Self {- base.set_path("");+ base.set_query(None);+ base.set_fragment(None);let client = reqwest::Client::new();Self { client, base }}- // pub async fn request(&self) -> Result<Option<BundleUpdate>, BundleClientErr> {- // }-}--impl UpdateRepo for BundleClient {- async fn check_for_update(+ fn update_check_url(&self,request: crate::domain::models::AppInfo,- ) -> Result<Option<BundleAction>, rootcause::Report> {+ ) -> Result<Url, BundleClientErr> {let mut url = self.base.clone();url.path_segments_mut().map_err(|_| BundleClientErr::CannotBeABase(self.base.clone()))?- .clear().push("update").push("bundle").push(request.target.into())@@ -59,6 +57,19 @@ impl UpdateRepo for BundleClient {&request.current_bundle_build.to_string(),).append_pair("native_build", &request.native_build.to_string());+ Ok(url)+ }++ // pub async fn request(&self) -> Result<Option<BundleUpdate>, BundleClientErr> {+ // }+}++impl UpdateRepo for BundleClient {+ async fn check_for_update(+ &self,+ request: crate::domain::models::AppInfo,+ ) -> Result<Option<BundleAction>, rootcause::Report> {+ let url = self.update_check_url(request)?;let res = self.client.get(url).send().await?.error_for_status()?;diff --git a/apps/web/tauri/macro_bundle_updater_plugin/src/outbound/api_client/test.rs b/apps/web/tauri/macro_bundle_updater_plugin/src/outbound/api_client/test.rsnew file mode 100644index 0000000000..bc029dc482--- /dev/null+++ b/apps/web/tauri/macro_bundle_updater_plugin/src/outbound/api_client/test.rs@@ -0,0 +1,51 @@+use super::*;+use crate::domain::models::{AppInfo, Arch, Target};++fn app_info() -> AppInfo {+ AppInfo {+ current_bundle_build: 42,+ native_build: 7,+ arch: Arch::Aarch64,+ target: Target::Ios,+ }+}++#[test]+fn update_check_url_preserves_base_path_prefix() {+ let client = BundleClient::new("https://gateway.macro.com/auth/".parse().unwrap());++ let url = client.update_check_url(app_info()).unwrap();++ assert_eq!(+ url.as_str(),+ "https://gateway.macro.com/auth/update/bundle/ios/aarch64?current_bundle_build=42&native_build=7"+ );+}++#[test]+fn update_check_url_still_supports_gateway_root_base() {+ let client = BundleClient::new("https://gateway.macro.com/".parse().unwrap());++ let url = client.update_check_url(app_info()).unwrap();++ assert_eq!(+ url.as_str(),+ "https://gateway.macro.com/update/bundle/ios/aarch64?current_bundle_build=42&native_build=7"+ );+}++#[test]+fn update_check_url_strips_base_query_and_fragment() {+ let client = BundleClient::new(+ "https://gateway.macro.com/auth/?stale=true#section"+ .parse()+ .unwrap(),+ );++ let url = client.update_check_url(app_info()).unwrap();++ assert_eq!(+ url.as_str(),+ "https://gateway.macro.com/auth/update/bundle/ios/aarch64?current_bundle_build=42&native_build=7"+ );+}