diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 39fd4699d..0e98b7f01 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -687,7 +687,77 @@ async fn get_base_branch_data( ) -> Result, Error> { let app = handle.state::(); let target = app.get_base_branch_data(project_id)?; - Ok(target) + + let out = match target { + None => Ok(target), + Some(t) => { + let proxy = handle.state::(); + let mut proxy_map = HashMap::new(); + let recent_commits_author_urls = t + .clone() + .recent_commits + .into_iter() + .map(|commit| commit.author.gravatar_url.clone()) + .collect::>(); + + let upstream_commits_author_urls = t + .clone() + .upstream_commits + .into_iter() + .map(|commit| commit.author.gravatar_url.clone()) + .collect::>(); + + let author_urls = recent_commits_author_urls + .into_iter() + .chain(upstream_commits_author_urls.into_iter()) + .collect::>(); + + for url in author_urls { + if !proxy_map.contains_key(&url) { + let proxied_url = proxy.proxy(&url).await?; + proxy_map.insert(url, proxied_url); + } + } + + let target = Some(virtual_branches::BaseBranch { + recent_commits: t + .clone() + .recent_commits + .into_iter() + .map(|commit| virtual_branches::VirtualBranchCommit { + author: virtual_branches::Author { + gravatar_url: proxy_map + .get(&commit.author.gravatar_url) + .unwrap() + .clone(), + ..commit.author + }, + ..commit + }) + .collect(), + upstream_commits: t + .clone() + .upstream_commits + .into_iter() + .map(|commit| virtual_branches::VirtualBranchCommit { + author: virtual_branches::Author { + gravatar_url: proxy_map + .get(&commit.author.gravatar_url) + .unwrap() + .clone(), + ..commit.author + }, + ..commit + }) + .collect(), + ..t + }); + + Ok(target) + } + }; + return out; + // Ok(target) } #[timed(duration(printer = "debug!"))]