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:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-05-22 17:37:54 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-05-22 17:37:54 +0100
commitb6407944cc8f670d33b828f7b77836ceeed2fcfa (patch)
treef95dcec39680d374eaeac801d31c34f715c08cca /src/lib
parent4dc5d0c9fb170981cf4fade5558d7cc8da404aa3 (diff)
feat(init): add blossom
add a blossom tag to the repo announcement
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/repo_ref.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs
index d37d7a9..1a0fe85 100644
--- a/src/lib/repo_ref.rs
+++ b/src/lib/repo_ref.rs
@@ -12,7 +12,7 @@ use nostr::{
12 FromBech32, PublicKey, Tag, TagStandard, ToBech32, 12 FromBech32, PublicKey, Tag, TagStandard, ToBech32,
13 nips::{nip01::Coordinate, nip19::Nip19Coordinate}, 13 nips::{nip01::Coordinate, nip19::Nip19Coordinate},
14}; 14};
15use nostr_sdk::{Kind, NostrSigner, RelayUrl, Timestamp}; 15use nostr_sdk::{Kind, NostrSigner, RelayUrl, Timestamp, Url};
16use serde::{Deserialize, Serialize}; 16use serde::{Deserialize, Serialize};
17 17
18#[cfg(not(test))] 18#[cfg(not(test))]
@@ -38,6 +38,7 @@ pub struct RepoRef {
38 pub git_server: Vec<String>, 38 pub git_server: Vec<String>,
39 pub web: Vec<String>, 39 pub web: Vec<String>,
40 pub relays: Vec<RelayUrl>, 40 pub relays: Vec<RelayUrl>,
41 pub blossoms: Vec<Url>,
41 pub maintainers: Vec<PublicKey>, 42 pub maintainers: Vec<PublicKey>,
42 pub trusted_maintainer: PublicKey, 43 pub trusted_maintainer: PublicKey,
43 pub events: HashMap<Nip19Coordinate, nostr::Event>, 44 pub events: HashMap<Nip19Coordinate, nostr::Event>,
@@ -61,6 +62,7 @@ impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef {
61 git_server: Vec::new(), 62 git_server: Vec::new(),
62 web: Vec::new(), 63 web: Vec::new(),
63 relays: Vec::new(), 64 relays: Vec::new(),
65 blossoms: Vec::new(),
64 maintainers: Vec::new(), 66 maintainers: Vec::new(),
65 trusted_maintainer: trusted_maintainer.unwrap_or(event.pubkey), 67 trusted_maintainer: trusted_maintainer.unwrap_or(event.pubkey),
66 events: HashMap::new(), 68 events: HashMap::new(),
@@ -100,6 +102,13 @@ impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef {
100 } 102 }
101 } 103 }
102 } 104 }
105 [t, blossoms @ ..] if t == "blossoms" => {
106 for b in blossoms {
107 if let Ok(b) = Url::parse(b) {
108 r.blossoms.push(b);
109 }
110 }
111 }
103 [t, maintainers @ ..] if t == "maintainers" => { 112 [t, maintainers @ ..] if t == "maintainers" => {
104 if !maintainers.contains(&event.pubkey.to_string()) { 113 if !maintainers.contains(&event.pubkey.to_string()) {
105 r.maintainers.push(event.pubkey); 114 r.maintainers.push(event.pubkey);
@@ -190,6 +199,14 @@ impl RepoRef {
190 vec![format!("git repository: {}", self.name.clone())], 199 vec![format!("git repository: {}", self.name.clone())],
191 ), 200 ),
192 ], 201 ],
202 if self.blossoms.is_empty() {
203 vec![]
204 } else {
205 vec![Tag::custom(
206 nostr::TagKind::Custom(std::borrow::Cow::Borrowed("blossoms")),
207 self.blossoms.iter().map(|r| r.to_string()),
208 )]
209 },
193 // code languages and hashtags 210 // code languages and hashtags
194 ] 211 ]
195 .concat(), 212 .concat(),
@@ -566,6 +583,7 @@ mod tests {
566 RelayUrl::parse("ws://relay1.io").unwrap(), 583 RelayUrl::parse("ws://relay1.io").unwrap(),
567 RelayUrl::parse("ws://relay2.io").unwrap(), 584 RelayUrl::parse("ws://relay2.io").unwrap(),
568 ], 585 ],
586 blossoms: vec![],
569 trusted_maintainer: TEST_KEY_1_KEYS.public_key(), 587 trusted_maintainer: TEST_KEY_1_KEYS.public_key(),
570 maintainers: vec![TEST_KEY_1_KEYS.public_key(), TEST_KEY_2_KEYS.public_key()], 588 maintainers: vec![TEST_KEY_1_KEYS.public_key(), TEST_KEY_2_KEYS.public_key()],
571 events: HashMap::new(), 589 events: HashMap::new(),