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 6, 2024
1 parent 9757eb2 commit e991ed3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion 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 @@ -229,7 +230,29 @@ impl JsEventBuilder {
builder: EventBuilder::live_event(live_event.into()),
}
}


#[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 e991ed3

Please sign in to comment.