From f15f530a1f8a95a74d249a5b88c538d3b2229842 Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Tue, 17 Oct 2023 15:12:02 +0200 Subject: [PATCH] nostr: add `identifier` method to `Event` --- crates/nostr/src/event/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/nostr/src/event/mod.rs b/crates/nostr/src/event/mod.rs index bbd27146a..8dbc378ee 100644 --- a/crates/nostr/src/event/mod.rs +++ b/crates/nostr/src/event/mod.rs @@ -223,6 +223,16 @@ impl Event { pub fn is_parameterized_replaceable(&self) -> bool { self.kind.is_parameterized_replaceable() } + + /// Extract identifier (`d` tag), if exists. + pub fn identifier(&self) -> Option<&str> { + for tag in self.tags.iter() { + if let Tag::Identifier(id) = tag { + return Some(id); + } + } + None + } } impl JsonUtil for Event {