diff --git a/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs b/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs index 79fa27a0d..abce1cc7b 100644 --- a/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs @@ -40,6 +40,12 @@ pub enum TagStandard { /// Whether the e tag is an uppercase E or not uppercase: bool, }, + Quote { + event_id: Arc, + relay_url: Option, + /// Should be the public key of the author of the referenced event + public_key: Option>, + }, /// Git clone (`clone` tag) /// /// @@ -295,6 +301,15 @@ impl From for TagStandard { public_key: public_key.map(|p| Arc::new(p.into())), uppercase, }, + tag::TagStandard::Quote { + event_id, + relay_url, + public_key, + } => Self::Quote { + event_id: Arc::new(event_id.into()), + relay_url: relay_url.map(|u| u.to_string()), + public_key: public_key.map(|p| Arc::new(p.into())), + }, tag::TagStandard::GitClone(urls) => Self::GitClone { urls: urls.into_iter().map(|r| r.to_string()).collect(), }, @@ -502,6 +517,15 @@ impl TryFrom for tag::TagStandard { public_key: public_key.map(|p| **p), uppercase, }), + TagStandard::Quote { + event_id, + relay_url, + public_key, + } => Ok(Self::Quote { + event_id: **event_id, + relay_url: relay_url.map(UncheckedUrl::from), + public_key: public_key.map(|p| **p), + }), TagStandard::GitClone { urls } => { let mut parsed_urls: Vec = Vec::with_capacity(urls.len()); for url in urls.into_iter() { diff --git a/crates/nostr/src/event/tag/kind.rs b/crates/nostr/src/event/tag/kind.rs index 9ae9c453a..5f656d800 100644 --- a/crates/nostr/src/event/tag/kind.rs +++ b/crates/nostr/src/event/tag/kind.rs @@ -166,6 +166,14 @@ impl<'a> TagKind<'a> { Self::SingleLetter(SingleLetterTag::lowercase(Alphabet::T)) } + /// Construct `q` kind + /// + /// Shorthand for `TagKind::SingleLetter(SingleLetterTag::lowercase(Alphabet::Q))`. + #[inline] + pub fn q() -> Self { + Self::SingleLetter(SingleLetterTag::lowercase(Alphabet::Q)) + } + /// Construct [`TagKind::Custom`] /// /// Shorthand for `TagKind::Custom(Cow::from(...))`. diff --git a/crates/nostr/src/event/tag/standard.rs b/crates/nostr/src/event/tag/standard.rs index 60abdb776..802bf6182 100644 --- a/crates/nostr/src/event/tag/standard.rs +++ b/crates/nostr/src/event/tag/standard.rs @@ -47,6 +47,15 @@ pub enum TagStandard { /// Whether the e tag is an uppercase E or not uppercase: bool, }, + /// Quote + /// + /// + Quote { + event_id: EventId, + relay_url: Option, + /// Should be the public key of the author of the referenced event + public_key: Option, + }, /// Report event /// /// @@ -468,6 +477,10 @@ impl TagStandard { character: Alphabet::E, uppercase: *uppercase, }), + Self::Quote { .. } => TagKind::SingleLetter(SingleLetterTag { + character: Alphabet::E, + uppercase: false, + }), Self::EventReport(..) => TagKind::SingleLetter(SingleLetterTag::lowercase(Alphabet::E)), Self::GitClone(..) => TagKind::Clone, Self::GitCommit(..) => TagKind::Commit, @@ -617,6 +630,22 @@ impl From for Vec { } tag } + TagStandard::Quote { + event_id, + relay_url, + public_key, + .. + } => { + let mut tag = vec![tag_kind, event_id.to_hex()]; + if let Some(relay_url) = relay_url { + tag.push(relay_url.to_string()); + } + if let Some(public_key) = public_key { + tag.resize_with(3, String::new); + tag.push(public_key.to_string()); + } + tag + } TagStandard::PublicKey { public_key, relay_url,