chore: Function to returns the event author if found

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-05-08 13:01:20 +00:00
parent 42508fc8b9
commit 2627fe7980

View File

@@ -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<Option<PublicKey>> {
Ok(self
.client
.fetch_events(Filter::new().id(event_id), CLIENT_TIMEOUT)
.await?
.first_owned()
.map(|e| e.pubkey))
}
}