notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 5bdb308b410d06cda72806b107a0caf4360704c4
parent a7acfa3191ce8c6e6368f8e3b5b26f1fdcfa783c
Author: kernelkind <kernelkind@gmail.com>
Date:   Mon,  2 Feb 2026 14:40:42 -0500

refactor(messages): new event prop Note instead of String

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck_messages/src/nip17/message.rs | 5++++-
Mcrates/notedeck_messages/src/nip17/mod.rs | 14+++++---------
2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/crates/notedeck_messages/src/nip17/message.rs b/crates/notedeck_messages/src/nip17/message.rs @@ -39,11 +39,14 @@ pub fn send_conversation_message( let mut rng = OsRng; for participant in &conversation.metadata.participants { - let Some(giftwrap_json) = + let Some(gifrwrap_note) = giftwrap_message(&mut rng, sender_secret, participant, &rumor_json) else { continue; }; + let Some(giftwrap_json) = gifrwrap_note.json().ok() else { + continue; + }; if participant == selected_kp.pubkey { if let Err(e) = ctx.ndb.process_client_event(&giftwrap_json) { tracing::error!("Could not ingest event: {e:?}"); diff --git a/crates/notedeck_messages/src/nip17/mod.rs b/crates/notedeck_messages/src/nip17/mod.rs @@ -37,7 +37,7 @@ pub fn giftwrap_message( sender_secret: &SecretKey, recipient: &Pubkey, rumor_json: &str, -) -> Option<String> { +) -> Option<Note<'static>> { let Some(recipient_pk) = nostrcrate_pk(recipient) else { tracing::warn!("failed to convert recipient pubkey {}", recipient); return None; @@ -79,7 +79,7 @@ pub fn giftwrap_message( }; let wrap_created = randomized_timestamp(rng); - build_giftwrap_json(&encrypted_seal, &wrap_keys, recipient, wrap_created) + build_giftwrap_note(&encrypted_seal, &wrap_keys, recipient, wrap_created) } fn build_seal_json( @@ -99,12 +99,12 @@ fn build_seal_json( .ok() } -fn build_giftwrap_json( +fn build_giftwrap_note( content: &str, wrap_keys: &FullKeypair, recipient: &Pubkey, created_at: u64, -) -> Option<String> { +) -> Option<Note<'static>> { let builder = NoteBuilder::new() .kind(1059) .content(content) @@ -113,11 +113,7 @@ fn build_giftwrap_json( .tag_str("p") .tag_str(&recipient.hex()); - builder - .sign(&wrap_keys.secret_key.secret_bytes()) - .build()? - .json() - .ok() + builder.sign(&wrap_keys.secret_key.secret_bytes()).build() } fn nostrcrate_pk(pk: &Pubkey) -> Option<PublicKey> {