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:
Diffstat (limited to 'src/repo_ref.rs')
-rw-r--r--src/repo_ref.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/repo_ref.rs b/src/repo_ref.rs
index c7b42fa..2dab79c 100644
--- a/src/repo_ref.rs
+++ b/src/repo_ref.rs
@@ -1,7 +1,7 @@
1use std::{fs::File, io::BufReader, str::FromStr}; 1use std::{fs::File, io::BufReader, str::FromStr};
2 2
3use anyhow::{bail, Context, Result}; 3use anyhow::{bail, Context, Result};
4use nostr::{nips::nip19::Nip19, secp256k1::XOnlyPublicKey, FromBech32, Tag, ToBech32}; 4use nostr::{nips::nip19::Nip19, FromBech32, PublicKey, Tag, ToBech32};
5use serde::{Deserialize, Serialize}; 5use serde::{Deserialize, Serialize};
6 6
7#[cfg(not(test))] 7#[cfg(not(test))]
@@ -23,7 +23,7 @@ pub struct RepoRef {
23 pub git_server: String, 23 pub git_server: String,
24 pub web: Vec<String>, 24 pub web: Vec<String>,
25 pub relays: Vec<String>, 25 pub relays: Vec<String>,
26 pub maintainers: Vec<XOnlyPublicKey>, 26 pub maintainers: Vec<PublicKey>,
27 // code languages and hashtags 27 // code languages and hashtags
28} 28}
29 29
@@ -78,7 +78,7 @@ impl TryFrom<nostr::Event> for RepoRef {
78 } 78 }
79 for pk in maintainers { 79 for pk in maintainers {
80 r.maintainers.push( 80 r.maintainers.push(
81 nostr_sdk::prelude::XOnlyPublicKey::from_str(&pk) 81 nostr_sdk::prelude::PublicKey::from_str(&pk)
82 .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) 82 .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format"))
83 .context("invalid repository event")?, 83 .context("invalid repository event")?,
84 ); 84 );
@@ -200,8 +200,9 @@ pub async fn fetch(
200 nostr::Filter::default().kind(nostr::Kind::Custom(REPO_REF_KIND)); 200 nostr::Filter::default().kind(nostr::Kind::Custom(REPO_REF_KIND));
201 match nip19 { 201 match nip19 {
202 Nip19::Coordinate(c) => { 202 Nip19::Coordinate(c) => {
203 repo_event_filter = 203 repo_event_filter = repo_event_filter
204 repo_event_filter.identifier(c.identifier).author(c.pubkey); 204 .identifier(c.identifier)
205 .author(c.public_key);
205 for r in c.relays { 206 for r in c.relays {
206 relays.push(r); 207 relays.push(r);
207 } 208 }
@@ -246,11 +247,11 @@ pub fn get_repo_config_from_yaml(git_repo: &Repo) -> Result<RepoConfigYaml> {
246 Ok(repo_config_yaml) 247 Ok(repo_config_yaml)
247} 248}
248 249
249pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<XOnlyPublicKey>> { 250pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<PublicKey>> {
250 let mut pks: Vec<XOnlyPublicKey> = vec![]; 251 let mut pks: Vec<PublicKey> = vec![];
251 for s in pk_strings { 252 for s in pk_strings {
252 pks.push( 253 pks.push(
253 nostr_sdk::prelude::XOnlyPublicKey::from_bech32(s.clone()) 254 nostr_sdk::prelude::PublicKey::from_bech32(s.clone())
254 .context(format!("cannot convert {s} into a valid nostr public key"))?, 255 .context(format!("cannot convert {s} into a valid nostr public key"))?,
255 ); 256 );
256 } 257 }
@@ -259,7 +260,7 @@ pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<XOnlyPublicKey>> {
259 260
260pub fn save_repo_config_to_yaml( 261pub fn save_repo_config_to_yaml(
261 git_repo: &Repo, 262 git_repo: &Repo,
262 maintainers: Vec<XOnlyPublicKey>, 263 maintainers: Vec<PublicKey>,
263 relays: Vec<String>, 264 relays: Vec<String>,
264) -> Result<()> { 265) -> Result<()> {
265 let path = git_repo.get_path()?.join("maintainers.yaml"); 266 let path = git_repo.get_path()?.join("maintainers.yaml");