Skip to content

Commit

Permalink
js(nostr): add EventBuilder::live_event_msg
Browse files Browse the repository at this point in the history
  • Loading branch information
rustedmoon committed Mar 7, 2024
1 parent 9757eb2 commit 5688fa7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bindings/nostr-js/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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<String>,
tags: Vec<JsTag>,
) -> Result<JsEventBuilder> {
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<JsTag>, content: String) -> Self {
Self {
Expand Down

0 comments on commit 5688fa7

Please sign in to comment.