diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-03-28 12:35:37 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-03-28 12:35:37 +0000 |
| commit | 4b06b2bd70d37656d727c8fffc0656c1aa3c7b97 (patch) | |
| tree | 1d885fdef21a7530c1a91f848788a665d6fc9948 /src/repo_ref.rs | |
| parent | 91a68de459b7d22a8dfb8a324e43740fca3e0a35 (diff) | |
| parent | 11dc9fa2d8b82594d3803f12d2c5a49e57026cfb (diff) | |
Merge upgrade rust-nostr v0.29
refactor to address breaking changes in rust-nostr
fix a number of in dependancy which have been upstreamed
Diffstat (limited to 'src/repo_ref.rs')
| -rw-r--r-- | src/repo_ref.rs | 19 |
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 @@ | |||
| 1 | use std::{fs::File, io::BufReader, str::FromStr}; | 1 | use std::{fs::File, io::BufReader, str::FromStr}; |
| 2 | 2 | ||
| 3 | use anyhow::{bail, Context, Result}; | 3 | use anyhow::{bail, Context, Result}; |
| 4 | use nostr::{nips::nip19::Nip19, secp256k1::XOnlyPublicKey, FromBech32, Tag, ToBech32}; | 4 | use nostr::{nips::nip19::Nip19, FromBech32, PublicKey, Tag, ToBech32}; |
| 5 | use serde::{Deserialize, Serialize}; | 5 | use 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 | ||
| 249 | pub fn extract_pks(pk_strings: Vec<String>) -> Result<Vec<XOnlyPublicKey>> { | 250 | pub 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 | ||
| 260 | pub fn save_repo_config_to_yaml( | 261 | pub 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"); |