From f7d520e9ccb6084144a3e963516e40a322add0c8 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:31 +0000 Subject: use Sha1Hashin new location it had moved from 'prelude' to 'hashes' --- src/sub_commands/send.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/sub_commands/send.rs') diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 35c2c81..cc182f1 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -4,10 +4,8 @@ use anyhow::{bail, Context, Result}; use console::Style; use futures::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use nostr::{ - nips::nip19::Nip19, prelude::sha1::Hash as Sha1Hash, EventBuilder, FromBech32, Marker, Tag, - TagKind, UncheckedUrl, -}; +use nostr::{nips::nip19::Nip19, EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl}; +use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use super::list::tag_value; #[cfg(not(test))] -- cgit v1.2.3 From 49bc478fffc63a3cad0be194c6c45a868e432691 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:40 +0000 Subject: update tag generation to reflect changes in rust-nostr --- src/key_handling/users.rs | 6 +++++- src/repo_ref.rs | 5 +++-- src/sub_commands/list.rs | 12 +++++++++--- src/sub_commands/send.rs | 31 ++++++++++++++++++++----------- tests/list.rs | 12 +++++++++--- tests/pull.rs | 10 ++++++++-- 6 files changed, 54 insertions(+), 22 deletions(-) (limited to 'src/sub_commands/send.rs') diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index 751c577..1dd75a8 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs @@ -249,7 +249,11 @@ impl UserManagement for UserManager { relays: new_relays_event .tags .iter() - .filter(|t| t.kind().eq(&nostr::TagKind::R)) + .filter(|t| { + t.kind().eq(&nostr::TagKind::SingleLetter( + SingleLetterTag::lowercase(Alphabet::R), + )) + }) .map(|t| UserRelayRef { url: t.as_vec()[1].clone(), read: t.as_vec().len() == 2 || t.as_vec()[2].eq("read"), diff --git a/src/repo_ref.rs b/src/repo_ref.rs index 0a14005..2dab79c 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs @@ -200,8 +200,9 @@ pub async fn fetch( nostr::Filter::default().kind(nostr::Kind::Custom(REPO_REF_KIND)); match nip19 { Nip19::Coordinate(c) => { - repo_event_filter = - repo_event_filter.identifier(c.identifier).author(c.pubkey); + repo_event_filter = repo_event_filter + .identifier(c.identifier) + .author(c.public_key); for r in c.relays { relays.push(r); } diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs index 2d81164..1a30b9b 100644 --- a/src/sub_commands/list.rs +++ b/src/sub_commands/list.rs @@ -730,9 +730,12 @@ pub async fn find_proposal_events( vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]) .custom_tag( - nostr::Alphabet::A, + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::A), repo_ref .maintainers .iter() @@ -742,7 +745,10 @@ pub async fn find_proposal_events( // events nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ) .reference(root_commit), ], ) diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index cc182f1..91654d2 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -4,7 +4,10 @@ use anyhow::{bail, Context, Result}; use console::Style; use futures::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use nostr::{nips::nip19::Nip19, EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl}; +use nostr::{ + nips::{nip01::Coordinate, nip19::Nip19}, + EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl, +}; use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use super::list::tag_value; @@ -539,11 +542,14 @@ pub fn generate_cover_letter_and_patch_events( vec![ // TODO: why not tag all maintainer identifiers? Tag::A { - kind: nostr::Kind::Custom(REPO_REF_KIND), - public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, - identifier: repo_ref.identifier.to_string(), + coordinate: Coordinate { + kind: nostr::Kind::Custom(REPO_REF_KIND), + public_key: *repo_ref.maintainers.first() + .context("repo reference should always have at least one maintainer - the issuer of the repo event") + ?, + identifier: repo_ref.identifier.to_string(), + relays: repo_ref.relays.clone(), + }, relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::from).clone(), }, Tag::Reference(format!("{root_commit}")), @@ -795,11 +801,14 @@ pub fn generate_patch_event( [ vec![ Tag::A { - kind: nostr::Kind::Custom(REPO_REF_KIND), - public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, - identifier: repo_ref.identifier.to_string(), + coordinate: Coordinate { + kind: nostr::Kind::Custom(REPO_REF_KIND), + public_key: *repo_ref.maintainers.first() + .context("repo reference should always have at least one maintainer - the issuer of the repo event") + ?, + identifier: repo_ref.identifier.to_string(), + relays: repo_ref.relays.clone(), + }, relay_url: relay_hint.clone(), }, Tag::Reference(format!("{root_commit}")), diff --git a/tests/list.rs b/tests/list.rs index 4f55645..ee5e1dc 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -190,7 +190,7 @@ mod cannot_find_repo_event { input.succeeds_with( &Coordinate { kind: nostr::Kind::Custom(REPOSITORY_KIND), - pubkey: TEST_KEY_1_KEYS.public_key(), + public_key: TEST_KEY_1_KEYS.public_key(), identifier: repo_event.identifier().unwrap().to_string(), relays: vec!["ws://localhost:8056".to_string()], } @@ -1621,7 +1621,10 @@ mod when_main_branch_is_uptodate { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; @@ -1748,7 +1751,10 @@ mod when_main_branch_is_uptodate { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; diff --git a/tests/pull.rs b/tests/pull.rs index 50dddbf..853f518 100644 --- a/tests/pull.rs +++ b/tests/pull.rs @@ -746,7 +746,10 @@ mod when_branch_is_checked_out { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; @@ -843,7 +846,10 @@ mod when_branch_is_checked_out { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; -- cgit v1.2.3 From 761484b6db6100a8b7f81e09f8903232f9f3ffaf Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 16:02:35 +0000 Subject: refactor: more concise error message to suppress the clippy too_many_lines in function warning --- src/sub_commands/send.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/sub_commands/send.rs') diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 91654d2..d9caf9b 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -545,8 +545,7 @@ pub fn generate_cover_letter_and_patch_events( coordinate: Coordinate { kind: nostr::Kind::Custom(REPO_REF_KIND), public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, + .context("repo reference should always have at least one maintainer")?, identifier: repo_ref.identifier.to_string(), relays: repo_ref.relays.clone(), }, -- cgit v1.2.3