From 5688fa7045b0c9e572d93adf4df33bd6371cec21 Mon Sep 17 00:00:00 2001 From: Rusted Moon Date: Wed, 28 Feb 2024 11:34:54 +0100 Subject: [PATCH] js(nostr): add `EventBuilder::live_event_msg` --- bindings/nostr-js/src/event/builder.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bindings/nostr-js/src/event/builder.rs b/bindings/nostr-js/src/event/builder.rs index 029b09671..081e68500 100644 --- a/bindings/nostr-js/src/event/builder.rs +++ b/bindings/nostr-js/src/event/builder.rs @@ -3,6 +3,7 @@ // Distributed under the MIT software license use core::ops::Deref; +use std::str::FromStr; use nostr::prelude::*; use wasm_bindgen::prelude::*; @@ -230,6 +231,28 @@ impl JsEventBuilder { } } + #[wasm_bindgen(js_name = liveEventMsg)] + pub fn live_event_msg( + live_event_id: String, + live_event_host: JsPublicKey, + content: String, + relay_url: Option, + tags: Vec, + ) -> Result { + Ok(Self { + builder: EventBuilder::live_event_msg( + live_event_id, + live_event_host.deref().to_owned(), + content, + match relay_url { + Some(url) => Some(Url::from_str(&url).map_err(into_err)?), + None => None, + }, + tags.into_iter().map(|t| t.into()).collect(), + ), + }) + } + #[wasm_bindgen] pub fn report(tags: Vec, content: String) -> Self { Self {