notedeck

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

commit faaa3c9d5485fba1e2987bfe3191ce6d55dbcc36
parent b0bca4aceb1210207f99c82828b2538c1b25c48a
Author: kernelkind <kernelkind@gmail.com>
Date:   Tue, 24 Feb 2026 18:27:42 -0500

feat(outbox-int): use `Outbox` for following

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

Diffstat:
Mcrates/notedeck/src/note/publish.rs | 28+++++++++++++++++++++++++++-
Mcrates/notedeck_columns/src/accounts/mod.rs | 17++++++++++-------
Mcrates/notedeck_columns/src/nav.rs | 1+
Mcrates/notedeck_columns/src/profile.rs | 43++++++++++++++++++++++++++++---------------
4 files changed, 66 insertions(+), 23 deletions(-)

diff --git a/crates/notedeck/src/note/publish.rs b/crates/notedeck/src/note/publish.rs @@ -2,7 +2,7 @@ use enostr::{FilledKeypair, NoteId, Pubkey, RelayPool}; use nostrdb::{Filter, Ndb, Note, NoteBuildOptions, NoteBuilder, Transaction}; use tracing::info; -use crate::Muted; +use crate::{Muted, PublishApi, RelayType}; #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum ReportType { @@ -104,6 +104,32 @@ pub fn send_note_builder(builder: NoteBuilder, ndb: &Ndb, pool: &mut RelayPool, pool.send(event); } +pub fn publish_note_builder( + builder: NoteBuilder, + ndb: &Ndb, + publisher: &mut PublishApi<'_, '_>, + kp: FilledKeypair, +) { + let note = builder + .sign(&kp.secret_key.secret_bytes()) + .build() + .expect("build note"); + + let Ok(event) = &enostr::ClientMessage::event(&note) 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(&json, nostrdb::IngestMetadata::new().client(true)); + info!("sending {}", &json); + publisher.publish_note(&note, RelayType::AccountsWrite); +} + pub fn send_unmute_event( ndb: &Ndb, txn: &Transaction, diff --git a/crates/notedeck_columns/src/accounts/mod.rs b/crates/notedeck_columns/src/accounts/mod.rs @@ -183,13 +183,16 @@ pub fn process_login_view_response( let kp = FullKeypair::generate(); - send_new_contact_list( - kp.to_filled(), - app_ctx.ndb, - app_ctx.legacy_pool, - pks_to_follow, - ); - send_default_dms_relay_list(kp.to_filled(), app_ctx.ndb, app_ctx.legacy_pool); + { + let mut publisher = app_ctx.remote.publisher(app_ctx.accounts); + send_new_contact_list( + kp.to_filled(), + app_ctx.ndb, + &mut publisher, + pks_to_follow, + ); + send_default_dms_relay_list(kp.to_filled(), app_ctx.ndb, &mut publisher); + } cur_router.go_back(); onboarding.end_onboarding(app_ctx.legacy_pool, app_ctx.ndb); diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs @@ -603,6 +603,7 @@ fn process_render_nav_action( ui.ctx(), ctx.ndb, ctx.legacy_pool, + &mut ctx.remote, ctx.accounts, ), RenderNavAction::WalletAction(wallet_action) => { diff --git a/crates/notedeck_columns/src/profile.rs b/crates/notedeck_columns/src/profile.rs @@ -2,8 +2,8 @@ use enostr::{FilledKeypair, FullKeypair, ProfileState, Pubkey, RelayPool}; use nostrdb::{Ndb, Note, NoteBuildOptions, NoteBuilder, Transaction}; use notedeck::{ - builder_from_note, send_mute_event, send_note_builder, Accounts, ContactState, DataPath, - Localization, ProfileContext, + builder_from_note, note::publish::publish_note_builder, send_mute_event, Accounts, + ContactState, DataPath, Localization, ProfileContext, PublishApi, RelayType, RemoteApi, }; use tracing::info; @@ -54,6 +54,7 @@ impl ProfileAction { ctx: &egui::Context, ndb: &Ndb, pool: &mut RelayPool, + remote: &mut RemoteApi<'_>, accounts: &Accounts, ) -> Option<RouterAction> { match self { @@ -74,16 +75,19 @@ impl ProfileAction { let _ = ndb.process_event_with(&json, nostrdb::IngestMetadata::new().client(true)); info!("sending {}", &json); - pool.send(&event); + let mut publisher = remote.publisher(accounts); + publisher.publish_note(&note, RelayType::AccountsWrite); Some(RouterAction::GoBack) } ProfileAction::Follow(target_key) => { - Self::send_follow_user_event(ndb, pool, accounts, target_key); + let mut publisher = remote.publisher(accounts); + Self::send_follow_user_event(ndb, &mut publisher, accounts, target_key); None } ProfileAction::Unfollow(target_key) => { - Self::send_unfollow_user_event(ndb, pool, accounts, target_key); + let mut publisher = remote.publisher(accounts); + Self::send_unfollow_user_event(ndb, &mut publisher, accounts, target_key); None } ProfileAction::Context(profile_context) => { @@ -156,20 +160,20 @@ impl ProfileAction { fn send_follow_user_event( ndb: &Ndb, - pool: &mut RelayPool, + publisher: &mut PublishApi<'_, '_>, accounts: &Accounts, target_key: &Pubkey, ) { - send_kind_3_event(ndb, pool, accounts, FollowAction::Follow(target_key)); + send_kind_3_event(ndb, publisher, accounts, FollowAction::Follow(target_key)); } fn send_unfollow_user_event( ndb: &Ndb, - pool: &mut RelayPool, + publisher: &mut PublishApi<'_, '_>, accounts: &Accounts, target_key: &Pubkey, ) { - send_kind_3_event(ndb, pool, accounts, FollowAction::Unfollow(target_key)); + send_kind_3_event(ndb, publisher, accounts, FollowAction::Unfollow(target_key)); } } @@ -178,7 +182,12 @@ enum FollowAction<'a> { Unfollow(&'a Pubkey), } -fn send_kind_3_event(ndb: &Ndb, pool: &mut RelayPool, accounts: &Accounts, action: FollowAction) { +fn send_kind_3_event( + ndb: &Ndb, + publisher: &mut PublishApi<'_, '_>, + accounts: &Accounts, + action: FollowAction, +) { let Some(kp) = accounts.get_selected_account().key.to_full() else { return; }; @@ -238,13 +247,13 @@ fn send_kind_3_event(ndb: &Ndb, pool: &mut RelayPool, accounts: &Accounts, actio ), }; - send_note_builder(builder, ndb, pool, kp); + publish_note_builder(builder, ndb, publisher, kp); } pub fn send_new_contact_list( kp: FilledKeypair, ndb: &Ndb, - pool: &mut RelayPool, + publisher: &mut PublishApi<'_, '_>, mut pks_to_follow: Vec<Pubkey>, ) { if !pks_to_follow.contains(kp.pubkey) { @@ -253,7 +262,7 @@ pub fn send_new_contact_list( let builder = construct_new_contact_list(pks_to_follow); - send_note_builder(builder, ndb, pool, kp); + publish_note_builder(builder, ndb, publisher, kp); } fn construct_new_contact_list<'a>(pks: Vec<Pubkey>) -> NoteBuilder<'a> { @@ -269,8 +278,12 @@ fn construct_new_contact_list<'a>(pks: Vec<Pubkey>) -> NoteBuilder<'a> { builder } -pub fn send_default_dms_relay_list(kp: FilledKeypair<'_>, ndb: &Ndb, pool: &mut RelayPool) { - send_note_builder(construct_default_dms_relay_list(), ndb, pool, kp); +pub fn send_default_dms_relay_list( + kp: FilledKeypair<'_>, + ndb: &Ndb, + publisher: &mut PublishApi<'_, '_>, +) { + publish_note_builder(construct_default_dms_relay_list(), ndb, publisher, kp); } fn construct_default_dms_relay_list<'a>() -> NoteBuilder<'a> {