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>
This commit is contained in:
William Casarin
2025-07-17 14:20:33 -07:00
parent 8a1398face
commit 8d2da86f1f
2 changed files with 26 additions and 18 deletions

View File

@@ -38,10 +38,6 @@ impl ClientMessage {
Ok(ClientMessage::Event(EventClientMessage { note_json })) 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 { pub fn req(sub_id: String, filters: Vec<Filter>) -> Self {
ClientMessage::Req { sub_id, filters } ClientMessage::Req { sub_id, filters }
} }

View File

@@ -50,15 +50,22 @@ impl ProfileAction {
match self { match self {
ProfileAction::Edit(kp) => Some(RouterAction::route_to(Route::EditProfile(kp.pubkey))), ProfileAction::Edit(kp) => Some(RouterAction::route_to(Route::EditProfile(kp.pubkey))),
ProfileAction::SaveChanges(changes) => { ProfileAction::SaveChanges(changes) => {
let raw_msg = format!("[\"EVENT\",{}]", changes.to_note().json().unwrap()); let note = changes.to_note();
let Ok(event) = enostr::ClientMessage::event(&note) else {
tracing::error!("could not serialize profile note?");
return None;
};
let _ = ndb.process_event_with( let Ok(json) = event.to_json() else {
raw_msg.as_str(), tracing::error!("could not serialize profile note?");
nostrdb::IngestMetadata::new().client(true), return None;
); };
info!("sending {}", raw_msg); // TODO(jb55): do this in a more centralized place
pool.send(&enostr::ClientMessage::raw(raw_msg)); let _ = ndb.process_event_with(&json, nostrdb::IngestMetadata::new().client(true));
info!("sending {}", &json);
pool.send(&event);
Some(RouterAction::GoBack) Some(RouterAction::GoBack)
} }
@@ -195,14 +202,19 @@ fn send_note_builder(builder: NoteBuilder, ndb: &Ndb, pool: &mut RelayPool, kp:
.build() .build()
.expect("build note"); .expect("build note");
let raw_msg = format!("[\"EVENT\",{}]", note.json().unwrap()); let Ok(event) = &enostr::ClientMessage::event(&note) else {
tracing::error!("send_note_builder: failed to build json");
return;
};
let _ = ndb.process_event_with( let Ok(json) = event.to_json() else {
raw_msg.as_str(), tracing::error!("send_note_builder: failed to build json");
nostrdb::IngestMetadata::new().client(true), return;
); };
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) { pub fn send_new_contact_list(kp: FilledKeypair, ndb: &Ndb, pool: &mut RelayPool) {