chore: A method to send an event builder
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -22,13 +22,13 @@ pub mod utils;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use nostr::{
|
use nostr::{
|
||||||
event::Kind,
|
event::{EventBuilder, EventId, Kind},
|
||||||
filter::Filter,
|
filter::Filter,
|
||||||
key::Keys,
|
key::Keys,
|
||||||
nips::{nip19::Nip19Coordinate, nip34::GitRepositoryAnnouncement},
|
nips::{nip19::Nip19Coordinate, nip34::GitRepositoryAnnouncement},
|
||||||
types::RelayUrl,
|
types::RelayUrl,
|
||||||
};
|
};
|
||||||
use nostr_sdk::Client;
|
use nostr_sdk::{Client, pool::Output};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::CliOptions,
|
cli::CliOptions,
|
||||||
@@ -83,6 +83,22 @@ impl NostrClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sends an event builder to the specified relays.
|
||||||
|
pub async fn send_builder_to(
|
||||||
|
&self,
|
||||||
|
builder: EventBuilder,
|
||||||
|
relays: &[RelayUrl],
|
||||||
|
) -> N34Result<Output<EventId>> {
|
||||||
|
for relay in relays {
|
||||||
|
let _ = self.client.add_write_relay(relay).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.client
|
||||||
|
.send_event_builder_to(relays, builder)
|
||||||
|
.await
|
||||||
|
.map_err(N34Error::from)
|
||||||
|
}
|
||||||
|
|
||||||
/// Try to fetch a repository and returns it
|
/// Try to fetch a repository and returns it
|
||||||
pub async fn fetch_repo(
|
pub async fn fetch_repo(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
Reference in New Issue
Block a user