From b6407944cc8f670d33b828f7b77836ceeed2fcfa Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 22 May 2025 17:37:54 +0100 Subject: feat(init): add blossom add a blossom tag to the repo announcement --- src/lib/repo_ref.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/lib') 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::{ FromBech32, PublicKey, Tag, TagStandard, ToBech32, nips::{nip01::Coordinate, nip19::Nip19Coordinate}, }; -use nostr_sdk::{Kind, NostrSigner, RelayUrl, Timestamp}; +use nostr_sdk::{Kind, NostrSigner, RelayUrl, Timestamp, Url}; use serde::{Deserialize, Serialize}; #[cfg(not(test))] @@ -38,6 +38,7 @@ pub struct RepoRef { pub git_server: Vec, pub web: Vec, pub relays: Vec, + pub blossoms: Vec, pub maintainers: Vec, pub trusted_maintainer: PublicKey, pub events: HashMap, @@ -61,6 +62,7 @@ impl TryFrom<(nostr::Event, Option)> for RepoRef { git_server: Vec::new(), web: Vec::new(), relays: Vec::new(), + blossoms: Vec::new(), maintainers: Vec::new(), trusted_maintainer: trusted_maintainer.unwrap_or(event.pubkey), events: HashMap::new(), @@ -100,6 +102,13 @@ impl TryFrom<(nostr::Event, Option)> for RepoRef { } } } + [t, blossoms @ ..] if t == "blossoms" => { + for b in blossoms { + if let Ok(b) = Url::parse(b) { + r.blossoms.push(b); + } + } + } [t, maintainers @ ..] if t == "maintainers" => { if !maintainers.contains(&event.pubkey.to_string()) { r.maintainers.push(event.pubkey); @@ -190,6 +199,14 @@ impl RepoRef { vec![format!("git repository: {}", self.name.clone())], ), ], + if self.blossoms.is_empty() { + vec![] + } else { + vec![Tag::custom( + nostr::TagKind::Custom(std::borrow::Cow::Borrowed("blossoms")), + self.blossoms.iter().map(|r| r.to_string()), + )] + }, // code languages and hashtags ] .concat(), @@ -566,6 +583,7 @@ mod tests { RelayUrl::parse("ws://relay1.io").unwrap(), RelayUrl::parse("ws://relay2.io").unwrap(), ], + blossoms: vec![], trusted_maintainer: TEST_KEY_1_KEYS.public_key(), maintainers: vec![TEST_KEY_1_KEYS.public_key(), TEST_KEY_2_KEYS.public_key()], events: HashMap::new(), -- cgit v1.2.3