From 2627fe7980641777e56cb83169112690d3fbdda5 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Thu, 8 May 2025 13:01:20 +0000 Subject: [PATCH] chore: Function to returns the event author if found Signed-off-by: Awiteb --- src/nostr_utils/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/nostr_utils/mod.rs b/src/nostr_utils/mod.rs index e863868..cc697ff 100644 --- a/src/nostr_utils/mod.rs +++ b/src/nostr_utils/mod.rs @@ -22,7 +22,7 @@ pub mod utils; use std::time::Duration; use nostr::{ - event::{Event, Kind, UnsignedEvent}, + event::{Event, EventId, Kind, UnsignedEvent}, filter::Filter, key::{Keys, PublicKey}, nips::{nip19::Nip19Coordinate, nip34::GitRepositoryAnnouncement}, @@ -148,4 +148,14 @@ impl NostrClient { .await? .first_owned()) } + + /// Gets the author of the specified event, if found. + pub async fn event_author(&self, event_id: EventId) -> N34Result> { + Ok(self + .client + .fetch_events(Filter::new().id(event_id), CLIENT_TIMEOUT) + .await? + .first_owned() + .map(|e| e.pubkey)) + } }