upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/client.rs6
-rw-r--r--src/lib/repo_ref.rs9
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/client.rs b/src/lib/client.rs
index bfa7b33..3b613b6 100644
--- a/src/lib/client.rs
+++ b/src/lib/client.rs
@@ -985,6 +985,9 @@ pub async fn get_repo_ref_from_cache(
985 .collect(); 985 .collect();
986 let mut seen_blossoms: HashSet<Url> = HashSet::from_iter(blossoms.iter().cloned()); 986 let mut seen_blossoms: HashSet<Url> = HashSet::from_iter(blossoms.iter().cloned());
987 987
988 // also set maintainers_without_annoucnement
989 let mut maintainers_without_annoucnement: Vec<PublicKey> = vec![];
990
988 for m in &maintainers { 991 for m in &maintainers {
989 if let Some(event) = repo_events.iter().find(|e| e.pubkey == *m) { 992 if let Some(event) = repo_events.iter().find(|e| e.pubkey == *m) {
990 if let Ok(m_repo_ref) = RepoRef::try_from((event.clone(), None)) { 993 if let Ok(m_repo_ref) = RepoRef::try_from((event.clone(), None)) {
@@ -1004,6 +1007,8 @@ pub async fn get_repo_ref_from_cache(
1004 } 1007 }
1005 } 1008 }
1006 } 1009 }
1010 } else {
1011 maintainers_without_annoucnement.push(*m);
1007 } 1012 }
1008 } 1013 }
1009 1014
@@ -1014,6 +1019,7 @@ pub async fn get_repo_ref_from_cache(
1014 relays, 1019 relays,
1015 git_server, 1020 git_server,
1016 events, 1021 events,
1022 maintainers_without_annoucnement: Some(maintainers_without_annoucnement),
1017 ..repo_ref 1023 ..repo_ref
1018 }) 1024 })
1019} 1025}
diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs
index bf52cda..78968b4 100644
--- a/src/lib/repo_ref.rs
+++ b/src/lib/repo_ref.rs
@@ -42,6 +42,8 @@ pub struct RepoRef {
42 pub blossoms: Vec<Url>, 42 pub blossoms: Vec<Url>,
43 pub maintainers: Vec<PublicKey>, 43 pub maintainers: Vec<PublicKey>,
44 pub trusted_maintainer: PublicKey, 44 pub trusted_maintainer: PublicKey,
45 // set to None if not known
46 pub maintainers_without_annoucnement: Option<Vec<PublicKey>>,
45 pub events: HashMap<Nip19Coordinate, nostr::Event>, 47 pub events: HashMap<Nip19Coordinate, nostr::Event>,
46 pub nostr_git_url: Option<NostrUrlDecoded>, 48 pub nostr_git_url: Option<NostrUrlDecoded>,
47} 49}
@@ -49,6 +51,11 @@ pub struct RepoRef {
49impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef { 51impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef {
50 type Error = anyhow::Error; 52 type Error = anyhow::Error;
51 53
54 /*
55 * this could do with a refactor to intergrate enhancements made by
56 * `get_repo_ref_from_cache`. Other than tests, its only used there and the
57 * changes made by that function are important.
58 */
52 fn try_from((event, trusted_maintainer): (nostr::Event, Option<PublicKey>)) -> Result<Self> { 59 fn try_from((event, trusted_maintainer): (nostr::Event, Option<PublicKey>)) -> Result<Self> {
53 // TODO: turn trusted maintainer into NostrUrlDecoded 60 // TODO: turn trusted maintainer into NostrUrlDecoded
54 if !event.kind.eq(&Kind::GitRepoAnnouncement) { 61 if !event.kind.eq(&Kind::GitRepoAnnouncement) {
@@ -66,6 +73,7 @@ impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef {
66 blossoms: Vec::new(), 73 blossoms: Vec::new(),
67 maintainers: Vec::new(), 74 maintainers: Vec::new(),
68 trusted_maintainer: trusted_maintainer.unwrap_or(event.pubkey), 75 trusted_maintainer: trusted_maintainer.unwrap_or(event.pubkey),
76 maintainers_without_annoucnement: None,
69 events: HashMap::new(), 77 events: HashMap::new(),
70 nostr_git_url: None, 78 nostr_git_url: None,
71 }; 79 };
@@ -740,6 +748,7 @@ mod tests {
740 ], 748 ],
741 blossoms: vec![], 749 blossoms: vec![],
742 trusted_maintainer: TEST_KEY_1_KEYS.public_key(), 750 trusted_maintainer: TEST_KEY_1_KEYS.public_key(),
751 maintainers_without_annoucnement: None,
743 maintainers: vec![TEST_KEY_1_KEYS.public_key(), TEST_KEY_2_KEYS.public_key()], 752 maintainers: vec![TEST_KEY_1_KEYS.public_key(), TEST_KEY_2_KEYS.public_key()],
744 events: HashMap::new(), 753 events: HashMap::new(),
745 nostr_git_url: None, 754 nostr_git_url: None,