diff --git a/crates/enostr/src/client/message.rs b/crates/enostr/src/client/message.rs index d6100a8f..0fc57ca1 100644 --- a/crates/enostr/src/client/message.rs +++ b/crates/enostr/src/client/message.rs @@ -38,10 +38,6 @@ impl ClientMessage { Ok(ClientMessage::Event(EventClientMessage { note_json })) } - pub fn raw(raw: String) -> Self { - ClientMessage::Raw(raw) - } - pub fn req(sub_id: String, filters: Vec) -> Self { ClientMessage::Req { sub_id, filters } } diff --git a/crates/notedeck_columns/src/profile.rs b/crates/notedeck_columns/src/profile.rs index 13fcf31d..9bd6c6df 100644 --- a/crates/notedeck_columns/src/profile.rs +++ b/crates/notedeck_columns/src/profile.rs @@ -50,15 +50,22 @@ impl ProfileAction { match self { ProfileAction::Edit(kp) => Some(RouterAction::route_to(Route::EditProfile(kp.pubkey))), ProfileAction::SaveChanges(changes) => { - let raw_msg = format!("[\"EVENT\",{}]", changes.to_note().json().unwrap()); + let note = changes.to_note(); + let Ok(event) = enostr::ClientMessage::event(¬e) else { + tracing::error!("could not serialize profile note?"); + return None; + }; - let _ = ndb.process_event_with( - raw_msg.as_str(), - nostrdb::IngestMetadata::new().client(true), - ); + let Ok(json) = event.to_json() else { + tracing::error!("could not serialize profile note?"); + return None; + }; - info!("sending {}", raw_msg); - pool.send(&enostr::ClientMessage::raw(raw_msg)); + // TODO(jb55): do this in a more centralized place + let _ = ndb.process_event_with(&json, nostrdb::IngestMetadata::new().client(true)); + + info!("sending {}", &json); + pool.send(&event); Some(RouterAction::GoBack) } @@ -195,14 +202,19 @@ fn send_note_builder(builder: NoteBuilder, ndb: &Ndb, pool: &mut RelayPool, kp: .build() .expect("build note"); - let raw_msg = format!("[\"EVENT\",{}]", note.json().unwrap()); + let Ok(event) = &enostr::ClientMessage::event(¬e) else { + tracing::error!("send_note_builder: failed to build json"); + return; + }; - let _ = ndb.process_event_with( - raw_msg.as_str(), - nostrdb::IngestMetadata::new().client(true), - ); - info!("sending {}", raw_msg); - pool.send(&enostr::ClientMessage::raw(raw_msg)); + let Ok(json) = event.to_json() else { + tracing::error!("send_note_builder: failed to build json"); + return; + }; + + let _ = ndb.process_event_with(&json, nostrdb::IngestMetadata::new().client(true)); + info!("sending {}", &json); + pool.send(event); } pub fn send_new_contact_list(kp: FilledKeypair, ndb: &Ndb, pool: &mut RelayPool) {