From 0379a7ad4c1c6876c32286adb1cf090e3afdc5ea Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 17 Jul 2024 17:33:29 +0100 Subject: fix(fetch): get profile with nsec cli parameter only the profile from the saved user was being fetched. tests are using cli login parameters and expecting to see the user's name but it was only showing the npub. fixed by allowing the explicit request of specfic user profiles. --- src/client.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/client.rs') diff --git a/src/client.rs b/src/client.rs index b6e93d6..7947a02 100644 --- a/src/client.rs +++ b/src/client.rs @@ -78,6 +78,7 @@ pub trait Connect { &self, git_repo_path: &Path, repo_coordinates: &HashSet, + user_profiles: &HashSet, ) -> Result<(Vec>, MultiProgress)>; async fn fetch_all_from_relay( &self, @@ -288,6 +289,7 @@ impl Connect for Client { &self, git_repo_path: &Path, repo_coordinates: &HashSet, + user_profiles: &HashSet, ) -> Result<(Vec>, MultiProgress)> { let fallback_relays = &self .fallback_relays @@ -295,8 +297,13 @@ impl Connect for Client { .filter_map(|r| Url::parse(r).ok()) .collect::>(); - let mut request = - create_relays_request(git_repo_path, repo_coordinates, fallback_relays.clone()).await?; + let mut request = create_relays_request( + git_repo_path, + repo_coordinates, + user_profiles, + fallback_relays.clone(), + ) + .await?; let progress_reporter = MultiProgress::new(); @@ -666,7 +673,7 @@ async fn get_global_cache_database(git_repo_path: &Path) -> Result, ) -> Result> { @@ -725,7 +732,7 @@ pub async fn get_repo_ref_from_cache( let events = [ get_event_from_global_cache(git_repo_path, vec![filter.clone()]).await?, - get_event_from_cache(git_repo_path, vec![filter]).await?, + get_events_from_cache(git_repo_path, vec![filter]).await?, ] .concat(); for e in events { @@ -778,6 +785,7 @@ pub async fn get_repo_ref_from_cache( async fn create_relays_request( git_repo_path: &Path, repo_coordinates: &HashSet, + user_profiles: &HashSet, fallback_relays: HashSet, ) -> Result { let repo_ref = get_repo_ref_from_cache(git_repo_path, repo_coordinates).await; @@ -799,7 +807,7 @@ async fn create_relays_request( } } - for event in &get_event_from_cache( + for event in &get_events_from_cache( git_repo_path, vec![ nostr::Filter::default() @@ -843,6 +851,7 @@ async fn create_relays_request( if let Some(current_user) = current_user { missing_contributor_profiles.insert(current_user); } + missing_contributor_profiles.extend(user_profiles); let existing_events: HashSet = { let mut existing_events: HashSet = HashSet::new(); -- cgit v1.2.3