commit 8d2da86f1fb997e7ca0fba895766fd58bc898373
parent 8a1398face6733dfdc0062f172654d7bfcfc9ba1
Author: William Casarin <jb55@jb55.com>
Date: Thu, 17 Jul 2025 14:20:33 -0700
enostr: remove raw event type
we rely on the event type for multicast logic,
so remove raw since its not really needed anymore
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 26 insertions(+), 18 deletions(-)
diff --git 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<Filter>) -> Self {
ClientMessage::Req { sub_id, filters }
}
diff --git 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 Ok(json) = event.to_json() else {
+ tracing::error!("could not serialize profile note?");
+ return None;
+ };
- let _ = ndb.process_event_with(
- raw_msg.as_str(),
- nostrdb::IngestMetadata::new().client(true),
- );
+ // TODO(jb55): do this in a more centralized place
+ let _ = ndb.process_event_with(&json, nostrdb::IngestMetadata::new().client(true));
- info!("sending {}", raw_msg);
- pool.send(&enostr::ClientMessage::raw(raw_msg));
+ 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 Ok(json) = event.to_json() 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 _ = 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) {