From 436ff29135e3deade80a6e53e53d74dddb613481 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 31 Jul 2025 16:28:04 +0100 Subject: fix: mention marker ~> q tag NIP-10 update required for rust-nostr v0.43 update --- src/bin/git_remote_nostr/push.rs | 4 +--- src/bin/ngit/sub_commands/send.rs | 23 +++++++++++++---------- src/lib/git_events.rs | 38 ++++++++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 73d76b4..9ba7c30 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -1209,12 +1209,10 @@ async fn create_merge_status( merged_patches .iter() .map(|merged_patch| { - Tag::from_standardized(nostr::TagStandard::Event { + Tag::from_standardized(nostr::TagStandard::Quote { event_id: *merged_patch, relay_url: repo_ref.relays.first().cloned(), - marker: Some(Marker::Mention), public_key: None, - uppercase: false, }) }) .collect::>(), diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index c84e339..8b49e37 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs @@ -4,12 +4,9 @@ use anyhow::{Context, Result, bail}; use console::Style; use ngit::{ client::{Params, send_events}, - git_events::generate_cover_letter_and_patch_events, -}; -use nostr::{ - ToBech32, - nips::{nip10::Marker, nip19::Nip19Event}, + git_events::{EventRefType, generate_cover_letter_and_patch_events}, }; +use nostr::{ToBech32, nips::nip19::Nip19Event}; use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use crate::{ @@ -368,7 +365,7 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( in_reply_to: &[String], ) -> Result<(Option, Vec)> { let root_proposal_id = if let Some(first) = in_reply_to.first() { - match event_tag_from_nip19_or_hex(first, "in-reply-to", Marker::Root, true, false)? + match event_tag_from_nip19_or_hex(first, "in-reply-to", EventRefType::Root, true, false)? .as_standardized() { Some(nostr_sdk::TagStandard::Event { @@ -404,10 +401,16 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( for (i, reply_to) in in_reply_to.iter().enumerate() { if i.ne(&0) || root_proposal_id.is_none() { mention_tags.push( - event_tag_from_nip19_or_hex(reply_to, "in-reply-to", Marker::Mention, true, false) - .context(format!( - "{reply_to} in 'in-reply-to' not a valid nostr reference" - ))?, + event_tag_from_nip19_or_hex( + reply_to, + "in-reply-to", + EventRefType::Quote, + true, + false, + ) + .context(format!( + "{reply_to} in 'in-reply-to' not a valid nostr reference" + ))?, ); } } diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs index 2e1f215..79f5772 100644 --- a/src/lib/git_events.rs +++ b/src/lib/git_events.rs @@ -184,7 +184,7 @@ pub async fn generate_patch_event( event_tag_from_nip19_or_hex( &event_ref, "proposal", - Marker::Reply, + EventRefType::Reply, false, false, )?, @@ -277,10 +277,17 @@ pub async fn generate_patch_event( .context("failed to sign event") } +#[derive(Debug, PartialEq)] +pub enum EventRefType { + Root, + Reply, + Quote, +} + pub fn event_tag_from_nip19_or_hex( reference: &str, reference_name: &str, - marker: Marker, + ref_type: EventRefType, allow_npub_reference: bool, prompt_for_correction: bool, ) -> Result { @@ -291,22 +298,41 @@ pub fn event_tag_from_nip19_or_hex( PromptInputParms::default().with_prompt(format!("{reference_name} reference")), )?; } + let marker = match ref_type { + EventRefType::Root => Some(Marker::Root), + EventRefType::Reply => Some(Marker::Reply), + EventRefType::Quote => None, + }; if let Ok(nip19) = Nip19::from_bech32(&bech32) { match nip19 { Nip19::Event(n) => { + if ref_type == EventRefType::Quote { + break Ok(Tag::from_standardized(nostr_sdk::TagStandard::Quote { + event_id: n.event_id, + relay_url: n.relays.first().cloned(), + public_key: None, + })); + } break Ok(Tag::from_standardized(nostr_sdk::TagStandard::Event { event_id: n.event_id, relay_url: n.relays.first().cloned(), - marker: Some(marker), + marker, public_key: None, uppercase: false, })); } Nip19::EventId(id) => { + if ref_type == EventRefType::Quote { + break Ok(Tag::from_standardized(nostr_sdk::TagStandard::Quote { + event_id: id, + relay_url: None, + public_key: None, + })); + } break Ok(Tag::from_standardized(nostr_sdk::TagStandard::Event { event_id: id, relay_url: None, - marker: Some(marker), + marker, public_key: None, uppercase: false, })); @@ -335,7 +361,7 @@ pub fn event_tag_from_nip19_or_hex( break Ok(Tag::from_standardized(nostr_sdk::TagStandard::Event { event_id: id, relay_url: None, - marker: Some(marker), + marker, public_key: None, uppercase: false, })); @@ -574,7 +600,7 @@ pub async fn generate_cover_letter_and_patch_events( Tag::hashtag("root"), Tag::hashtag("revision-root"), // TODO check if id is for a root proposal (perhaps its for an issue?) - event_tag_from_nip19_or_hex(&event_ref,"proposal",Marker::Reply, false, false)?, + event_tag_from_nip19_or_hex(&event_ref,"proposal",EventRefType::Reply, false, false)?, ] } else { vec![ -- cgit v1.2.3