diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-17 17:33:29 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-17 17:34:27 +0100 |
| commit | 0379a7ad4c1c6876c32286adb1cf090e3afdc5ea (patch) | |
| tree | 3ebde10b399214bc6509bb81806088bb7b552383 /src/client.rs | |
| parent | 7227db8d2a506912eb5ffd3d25dee1c95544cbf4 (diff) | |
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.
Diffstat (limited to 'src/client.rs')
| -rw-r--r-- | src/client.rs | 19 |
1 files changed, 14 insertions, 5 deletions
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 { | |||
| 78 | &self, | 78 | &self, |
| 79 | git_repo_path: &Path, | 79 | git_repo_path: &Path, |
| 80 | repo_coordinates: &HashSet<Coordinate>, | 80 | repo_coordinates: &HashSet<Coordinate>, |
| 81 | user_profiles: &HashSet<PublicKey>, | ||
| 81 | ) -> Result<(Vec<Result<FetchReport>>, MultiProgress)>; | 82 | ) -> Result<(Vec<Result<FetchReport>>, MultiProgress)>; |
| 82 | async fn fetch_all_from_relay( | 83 | async fn fetch_all_from_relay( |
| 83 | &self, | 84 | &self, |
| @@ -288,6 +289,7 @@ impl Connect for Client { | |||
| 288 | &self, | 289 | &self, |
| 289 | git_repo_path: &Path, | 290 | git_repo_path: &Path, |
| 290 | repo_coordinates: &HashSet<Coordinate>, | 291 | repo_coordinates: &HashSet<Coordinate>, |
| 292 | user_profiles: &HashSet<PublicKey>, | ||
| 291 | ) -> Result<(Vec<Result<FetchReport>>, MultiProgress)> { | 293 | ) -> Result<(Vec<Result<FetchReport>>, MultiProgress)> { |
| 292 | let fallback_relays = &self | 294 | let fallback_relays = &self |
| 293 | .fallback_relays | 295 | .fallback_relays |
| @@ -295,8 +297,13 @@ impl Connect for Client { | |||
| 295 | .filter_map(|r| Url::parse(r).ok()) | 297 | .filter_map(|r| Url::parse(r).ok()) |
| 296 | .collect::<HashSet<Url>>(); | 298 | .collect::<HashSet<Url>>(); |
| 297 | 299 | ||
| 298 | let mut request = | 300 | let mut request = create_relays_request( |
| 299 | create_relays_request(git_repo_path, repo_coordinates, fallback_relays.clone()).await?; | 301 | git_repo_path, |
| 302 | repo_coordinates, | ||
| 303 | user_profiles, | ||
| 304 | fallback_relays.clone(), | ||
| 305 | ) | ||
| 306 | .await?; | ||
| 300 | 307 | ||
| 301 | let progress_reporter = MultiProgress::new(); | 308 | let progress_reporter = MultiProgress::new(); |
| 302 | 309 | ||
| @@ -666,7 +673,7 @@ async fn get_global_cache_database(git_repo_path: &Path) -> Result<SQLiteDatabas | |||
| 666 | .context("cannot open ngit global nostr cache database") | 673 | .context("cannot open ngit global nostr cache database") |
| 667 | } | 674 | } |
| 668 | 675 | ||
| 669 | pub async fn get_event_from_cache( | 676 | pub async fn get_events_from_cache( |
| 670 | git_repo_path: &Path, | 677 | git_repo_path: &Path, |
| 671 | filters: Vec<nostr::Filter>, | 678 | filters: Vec<nostr::Filter>, |
| 672 | ) -> Result<Vec<nostr::Event>> { | 679 | ) -> Result<Vec<nostr::Event>> { |
| @@ -725,7 +732,7 @@ pub async fn get_repo_ref_from_cache( | |||
| 725 | 732 | ||
| 726 | let events = [ | 733 | let events = [ |
| 727 | get_event_from_global_cache(git_repo_path, vec![filter.clone()]).await?, | 734 | get_event_from_global_cache(git_repo_path, vec![filter.clone()]).await?, |
| 728 | get_event_from_cache(git_repo_path, vec![filter]).await?, | 735 | get_events_from_cache(git_repo_path, vec![filter]).await?, |
| 729 | ] | 736 | ] |
| 730 | .concat(); | 737 | .concat(); |
| 731 | for e in events { | 738 | for e in events { |
| @@ -778,6 +785,7 @@ pub async fn get_repo_ref_from_cache( | |||
| 778 | async fn create_relays_request( | 785 | async fn create_relays_request( |
| 779 | git_repo_path: &Path, | 786 | git_repo_path: &Path, |
| 780 | repo_coordinates: &HashSet<Coordinate>, | 787 | repo_coordinates: &HashSet<Coordinate>, |
| 788 | user_profiles: &HashSet<PublicKey>, | ||
| 781 | fallback_relays: HashSet<Url>, | 789 | fallback_relays: HashSet<Url>, |
| 782 | ) -> Result<FetchRequest> { | 790 | ) -> Result<FetchRequest> { |
| 783 | let repo_ref = get_repo_ref_from_cache(git_repo_path, repo_coordinates).await; | 791 | let repo_ref = get_repo_ref_from_cache(git_repo_path, repo_coordinates).await; |
| @@ -799,7 +807,7 @@ async fn create_relays_request( | |||
| 799 | } | 807 | } |
| 800 | } | 808 | } |
| 801 | 809 | ||
| 802 | for event in &get_event_from_cache( | 810 | for event in &get_events_from_cache( |
| 803 | git_repo_path, | 811 | git_repo_path, |
| 804 | vec![ | 812 | vec![ |
| 805 | nostr::Filter::default() | 813 | nostr::Filter::default() |
| @@ -843,6 +851,7 @@ async fn create_relays_request( | |||
| 843 | if let Some(current_user) = current_user { | 851 | if let Some(current_user) = current_user { |
| 844 | missing_contributor_profiles.insert(current_user); | 852 | missing_contributor_profiles.insert(current_user); |
| 845 | } | 853 | } |
| 854 | missing_contributor_profiles.extend(user_profiles); | ||
| 846 | 855 | ||
| 847 | let existing_events: HashSet<EventId> = { | 856 | let existing_events: HashSet<EventId> = { |
| 848 | let mut existing_events: HashSet<EventId> = HashSet::new(); | 857 | let mut existing_events: HashSet<EventId> = HashSet::new(); |