From fc4d4ea8559f39316f59d5de396df95e70e5744b Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Wed, 11 Oct 2023 10:03:02 +0200 Subject: [PATCH] nostr: add `relay_list` constructor to `EventBuilder` --- crates/nostr/src/event/builder.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/nostr/src/event/builder.rs b/crates/nostr/src/event/builder.rs index 4fc283890..b1e834e12 100644 --- a/crates/nostr/src/event/builder.rs +++ b/crates/nostr/src/event/builder.rs @@ -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)] @@ -298,6 +298,17 @@ impl EventBuilder { Self::new(Kind::RecommendRelay, url.as_ref(), &[]) } + /// Relay list metadata (NIP65) + /// + /// + pub fn relay_list(list: Vec<(UncheckedUrl, Option)>) -> Self { + let tags: Vec = list + .into_iter() + .map(|(url, metadata)| Tag::RelayMetadata(url, metadata)) + .collect(); + Self::new(Kind::RelayList, "", &tags) + } + /// Text note /// ///