upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/key_handling/users.rs6
-rw-r--r--src/repo_ref.rs5
-rw-r--r--src/sub_commands/list.rs12
-rw-r--r--src/sub_commands/send.rs31
-rw-r--r--tests/list.rs12
-rw-r--r--tests/pull.rs10
6 files changed, 54 insertions, 22 deletions
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 {
249 relays: new_relays_event 249 relays: new_relays_event
250 .tags 250 .tags
251 .iter() 251 .iter()
252 .filter(|t| t.kind().eq(&nostr::TagKind::R)) 252 .filter(|t| {
253 t.kind().eq(&nostr::TagKind::SingleLetter(
254 SingleLetterTag::lowercase(Alphabet::R),
255 ))
256 })
253 .map(|t| UserRelayRef { 257 .map(|t| UserRelayRef {
254 url: t.as_vec()[1].clone(), 258 url: t.as_vec()[1].clone(),
255 read: t.as_vec().len() == 2 || t.as_vec()[2].eq("read"), 259 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(
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 }
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(
730 vec![ 730 vec![
731 nostr::Filter::default() 731 nostr::Filter::default()
732 .kind(nostr::Kind::Custom(PATCH_KIND)) 732 .kind(nostr::Kind::Custom(PATCH_KIND))
733 .custom_tag(nostr::Alphabet::T, vec!["root"])
734 .custom_tag( 733 .custom_tag(
735 nostr::Alphabet::A, 734 nostr::SingleLetterTag::lowercase(nostr::Alphabet::T),
735 vec!["root"],
736 )
737 .custom_tag(
738 nostr::SingleLetterTag::lowercase(nostr::Alphabet::A),
736 repo_ref 739 repo_ref
737 .maintainers 740 .maintainers
738 .iter() 741 .iter()
@@ -742,7 +745,10 @@ pub async fn find_proposal_events(
742 // events 745 // events
743 nostr::Filter::default() 746 nostr::Filter::default()
744 .kind(nostr::Kind::Custom(PATCH_KIND)) 747 .kind(nostr::Kind::Custom(PATCH_KIND))
745 .custom_tag(nostr::Alphabet::T, vec!["root"]) 748 .custom_tag(
749 nostr::SingleLetterTag::lowercase(nostr::Alphabet::T),
750 vec!["root"],
751 )
746 .reference(root_commit), 752 .reference(root_commit),
747 ], 753 ],
748 ) 754 )
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};
4use console::Style; 4use console::Style;
5use futures::future::join_all; 5use futures::future::join_all;
6use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; 6use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
7use nostr::{nips::nip19::Nip19, EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl}; 7use nostr::{
8 nips::{nip01::Coordinate, nip19::Nip19},
9 EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl,
10};
8use nostr_sdk::hashes::sha1::Hash as Sha1Hash; 11use nostr_sdk::hashes::sha1::Hash as Sha1Hash;
9 12
10use super::list::tag_value; 13use super::list::tag_value;
@@ -539,11 +542,14 @@ pub fn generate_cover_letter_and_patch_events(
539 vec![ 542 vec![
540 // TODO: why not tag all maintainer identifiers? 543 // TODO: why not tag all maintainer identifiers?
541 Tag::A { 544 Tag::A {
542 kind: nostr::Kind::Custom(REPO_REF_KIND), 545 coordinate: Coordinate {
543 public_key: *repo_ref.maintainers.first() 546 kind: nostr::Kind::Custom(REPO_REF_KIND),
544 .context("repo reference should always have at least one maintainer - the issuer of the repo event") 547 public_key: *repo_ref.maintainers.first()
545 ?, 548 .context("repo reference should always have at least one maintainer - the issuer of the repo event")
546 identifier: repo_ref.identifier.to_string(), 549 ?,
550 identifier: repo_ref.identifier.to_string(),
551 relays: repo_ref.relays.clone(),
552 },
547 relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::from).clone(), 553 relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::from).clone(),
548 }, 554 },
549 Tag::Reference(format!("{root_commit}")), 555 Tag::Reference(format!("{root_commit}")),
@@ -795,11 +801,14 @@ pub fn generate_patch_event(
795 [ 801 [
796 vec![ 802 vec![
797 Tag::A { 803 Tag::A {
798 kind: nostr::Kind::Custom(REPO_REF_KIND), 804 coordinate: Coordinate {
799 public_key: *repo_ref.maintainers.first() 805 kind: nostr::Kind::Custom(REPO_REF_KIND),
800 .context("repo reference should always have at least one maintainer - the issuer of the repo event") 806 public_key: *repo_ref.maintainers.first()
801 ?, 807 .context("repo reference should always have at least one maintainer - the issuer of the repo event")
802 identifier: repo_ref.identifier.to_string(), 808 ?,
809 identifier: repo_ref.identifier.to_string(),
810 relays: repo_ref.relays.clone(),
811 },
803 relay_url: relay_hint.clone(), 812 relay_url: relay_hint.clone(),
804 }, 813 },
805 Tag::Reference(format!("{root_commit}")), 814 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 {
190 input.succeeds_with( 190 input.succeeds_with(
191 &Coordinate { 191 &Coordinate {
192 kind: nostr::Kind::Custom(REPOSITORY_KIND), 192 kind: nostr::Kind::Custom(REPOSITORY_KIND),
193 pubkey: TEST_KEY_1_KEYS.public_key(), 193 public_key: TEST_KEY_1_KEYS.public_key(),
194 identifier: repo_event.identifier().unwrap().to_string(), 194 identifier: repo_event.identifier().unwrap().to_string(),
195 relays: vec!["ws://localhost:8056".to_string()], 195 relays: vec!["ws://localhost:8056".to_string()],
196 } 196 }
@@ -1621,7 +1621,10 @@ mod when_main_branch_is_uptodate {
1621 vec![ 1621 vec![
1622 nostr::Filter::default() 1622 nostr::Filter::default()
1623 .kind(nostr::Kind::Custom(PATCH_KIND)) 1623 .kind(nostr::Kind::Custom(PATCH_KIND))
1624 .custom_tag(nostr::Alphabet::T, vec!["root"]), 1624 .custom_tag(
1625 nostr::SingleLetterTag::lowercase(nostr::Alphabet::T),
1626 vec!["root"],
1627 ),
1625 ], 1628 ],
1626 Some(Duration::from_millis(500)), 1629 Some(Duration::from_millis(500)),
1627 )?; 1630 )?;
@@ -1748,7 +1751,10 @@ mod when_main_branch_is_uptodate {
1748 vec![ 1751 vec![
1749 nostr::Filter::default() 1752 nostr::Filter::default()
1750 .kind(nostr::Kind::Custom(PATCH_KIND)) 1753 .kind(nostr::Kind::Custom(PATCH_KIND))
1751 .custom_tag(nostr::Alphabet::T, vec!["root"]), 1754 .custom_tag(
1755 nostr::SingleLetterTag::lowercase(nostr::Alphabet::T),
1756 vec!["root"],
1757 ),
1752 ], 1758 ],
1753 Some(Duration::from_millis(500)), 1759 Some(Duration::from_millis(500)),
1754 )?; 1760 )?;
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 {
746 vec![ 746 vec![
747 nostr::Filter::default() 747 nostr::Filter::default()
748 .kind(nostr::Kind::Custom(PATCH_KIND)) 748 .kind(nostr::Kind::Custom(PATCH_KIND))
749 .custom_tag(nostr::Alphabet::T, vec!["root"]), 749 .custom_tag(
750 nostr::SingleLetterTag::lowercase(nostr::Alphabet::T),
751 vec!["root"],
752 ),
750 ], 753 ],
751 Some(Duration::from_millis(500)), 754 Some(Duration::from_millis(500)),
752 )?; 755 )?;
@@ -843,7 +846,10 @@ mod when_branch_is_checked_out {
843 vec![ 846 vec![
844 nostr::Filter::default() 847 nostr::Filter::default()
845 .kind(nostr::Kind::Custom(PATCH_KIND)) 848 .kind(nostr::Kind::Custom(PATCH_KIND))
846 .custom_tag(nostr::Alphabet::T, vec!["root"]), 849 .custom_tag(
850 nostr::SingleLetterTag::lowercase(nostr::Alphabet::T),
851 vec!["root"],
852 ),
847 ], 853 ],
848 Some(Duration::from_millis(500)), 854 Some(Duration::from_millis(500)),
849 )?; 855 )?;