upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/repo_ref.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-07-24 16:37:10 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-07-24 16:37:10 +0100
commit8638b321fdff94d034ec912ecd0910b6f564ff04 (patch)
tree411e0ca989d8c53be5b11b39461297bf6a92d781 /src/repo_ref.rs
parent95cb9c040dfa8ca18bf907a44a86df35b316b6ca (diff)
refactor: use nip34 kinds from rust-nostr
instead of Kind::Custom(u16) as v33 of rust-nostr introduced them
Diffstat (limited to 'src/repo_ref.rs')
-rw-r--r--src/repo_ref.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/repo_ref.rs b/src/repo_ref.rs
index 0409502..ca196d9 100644
--- a/src/repo_ref.rs
+++ b/src/repo_ref.rs
@@ -37,7 +37,7 @@ impl TryFrom<nostr::Event> for RepoRef {
37 type Error = anyhow::Error; 37 type Error = anyhow::Error;
38 38
39 fn try_from(event: nostr::Event) -> Result<Self> { 39 fn try_from(event: nostr::Event) -> Result<Self> {
40 if !event.kind.as_u16().eq(&REPO_REF_KIND) { 40 if !event.kind.eq(&Kind::GitRepoAnnouncement) {
41 bail!("incorrect kind"); 41 bail!("incorrect kind");
42 } 42 }
43 let mut r = Self::default(); 43 let mut r = Self::default();
@@ -107,13 +107,11 @@ impl TryFrom<nostr::Event> for RepoRef {
107 } 107 }
108} 108}
109 109
110pub static REPO_REF_KIND: u16 = 30_617;
111
112impl RepoRef { 110impl RepoRef {
113 pub async fn to_event(&self, signer: &NostrSigner) -> Result<nostr::Event> { 111 pub async fn to_event(&self, signer: &NostrSigner) -> Result<nostr::Event> {
114 sign_event( 112 sign_event(
115 nostr_sdk::EventBuilder::new( 113 nostr_sdk::EventBuilder::new(
116 nostr::event::Kind::Custom(REPO_REF_KIND), 114 nostr::event::Kind::GitRepoAnnouncement,
117 "", 115 "",
118 [ 116 [
119 vec![ 117 vec![
@@ -179,7 +177,7 @@ impl RepoRef {
179 let mut res = HashSet::new(); 177 let mut res = HashSet::new();
180 for m in &self.maintainers { 178 for m in &self.maintainers {
181 res.insert(Coordinate { 179 res.insert(Coordinate {
182 kind: Kind::Custom(REPO_REF_KIND), 180 kind: Kind::GitRepoAnnouncement,
183 public_key: *m, 181 public_key: *m,
184 identifier: self.identifier.clone(), 182 identifier: self.identifier.clone(),
185 relays: vec![], 183 relays: vec![],
@@ -191,7 +189,7 @@ impl RepoRef {
191 /// coordinates without relay hints 189 /// coordinates without relay hints
192 pub fn coordinate_with_hint(&self) -> Coordinate { 190 pub fn coordinate_with_hint(&self) -> Coordinate {
193 Coordinate { 191 Coordinate {
194 kind: Kind::Custom(REPO_REF_KIND), 192 kind: Kind::GitRepoAnnouncement,
195 public_key: *self 193 public_key: *self
196 .maintainers 194 .maintainers
197 .first() 195 .first()
@@ -256,7 +254,7 @@ pub async fn try_and_get_repo_coordinates(
256 if let Some(identifier) = repo_config.identifier { 254 if let Some(identifier) = repo_config.identifier {
257 for public_key in maintainers { 255 for public_key in maintainers {
258 repo_coordinates.insert(Coordinate { 256 repo_coordinates.insert(Coordinate {
259 kind: Kind::Custom(REPO_REF_KIND), 257 kind: Kind::GitRepoAnnouncement,
260 public_key, 258 public_key,
261 identifier: identifier.clone(), 259 identifier: identifier.clone(),
262 relays: vec![], 260 relays: vec![],
@@ -283,7 +281,7 @@ pub async fn try_and_get_repo_coordinates(
283 } 281 }
284 // look find all repo refs with root_commit. for identifier 282 // look find all repo refs with root_commit. for identifier
285 let filter = nostr::Filter::default() 283 let filter = nostr::Filter::default()
286 .kind(nostr::Kind::Custom(REPO_REF_KIND)) 284 .kind(nostr::Kind::GitRepoAnnouncement)
287 .reference(git_repo.get_root_commit()?.to_string()) 285 .reference(git_repo.get_root_commit()?.to_string())
288 .authors(maintainers.clone()); 286 .authors(maintainers.clone());
289 let mut events = 287 let mut events =
@@ -306,7 +304,7 @@ pub async fn try_and_get_repo_coordinates(
306 for m in &repo_config.maintainers { 304 for m in &repo_config.maintainers {
307 if let Ok(maintainer) = PublicKey::parse(m) { 305 if let Ok(maintainer) = PublicKey::parse(m) {
308 repo_coordinates.insert(Coordinate { 306 repo_coordinates.insert(Coordinate {
309 kind: Kind::Custom(REPO_REF_KIND), 307 kind: Kind::GitRepoAnnouncement,
310 public_key: maintainer, 308 public_key: maintainer,
311 identifier: identifier.to_string(), 309 identifier: identifier.to_string(),
312 relays: vec![], 310 relays: vec![],