Skip to content

Commit

Permalink
nostr: add relay_list constructor to EventBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Oct 11, 2023
1 parent 8ee3cc4 commit fc4d4ea
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/nostr/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::types::time::TimeSupplier;
use crate::types::{ChannelId, Contact, Metadata, Timestamp};
#[cfg(feature = "std")]
use crate::SECP256K1;
use crate::{JsonUtil, UncheckedUrl};
use crate::{JsonUtil, RelayMetadata, UncheckedUrl};

/// [`EventBuilder`] error
#[derive(Debug)]
Expand Down Expand Up @@ -298,6 +298,17 @@ impl EventBuilder {
Self::new(Kind::RecommendRelay, url.as_ref(), &[])
}

/// Relay list metadata (NIP65)
///
/// <https://github.com/nostr-protocol/nips/blob/master/65.md>
pub fn relay_list(list: Vec<(UncheckedUrl, Option<RelayMetadata>)>) -> Self {
let tags: Vec<Tag> = list
.into_iter()
.map(|(url, metadata)| Tag::RelayMetadata(url, metadata))
.collect();
Self::new(Kind::RelayList, "", &tags)
}

/// Text note
///
/// <https://github.com/nostr-protocol/nips/blob/master/01.md>
Expand Down

0 comments on commit fc4d4ea

Please sign in to comment.