diff --git a/bin/chat-cli/src/main.rs b/bin/chat-cli/src/main.rs index ed3f7ea..9a35b45 100644 --- a/bin/chat-cli/src/main.rs +++ b/bin/chat-cli/src/main.rs @@ -191,18 +191,22 @@ fn run_logos_delivery(cli: Cli) -> Result<()> { .to_str() .context("db path contains non-UTF-8 characters")? .to_string(); - logos_chat::ChatClient::open( - cli.name.clone(), - logos_chat::StorageConfig::Encrypted { + + logos_chat::ChatClientBuilder::new() + .storage_config(logos_chat::StorageConfig::Encrypted { path: db_str, key: "chat-cli".to_string(), - }, - delivery, - ) - .map_err(|e| anyhow::anyhow!("{e:?}")) - .context("failed to open persistent client")? + }) + .transport(delivery) + .build() + .map_err(|e| anyhow::anyhow!("{e:?}")) + .context("failed to open persistent client")? } - None => logos_chat::ChatClient::new(cli.name.clone(), delivery), + None => logos_chat::ChatClientBuilder::new() + .transport(delivery) + .build() + .map_err(|e| anyhow::anyhow!("{e:?}")) + .context("failed to open chat client")?, }; let mut app = ChatApp::new(client, events, &cli.name, &data_dir)?; diff --git a/core/conversations/src/conversation/group_v1.rs b/core/conversations/src/conversation/group_v1.rs index 19b77ba..b562a4a 100644 --- a/core/conversations/src/conversation/group_v1.rs +++ b/core/conversations/src/conversation/group_v1.rs @@ -26,6 +26,8 @@ use crate::{ types::AddressedEncryptedPayload, }; +const OUTBOUND_HASH_CACHE_SIZE: usize = 25; + pub struct GroupV1Convo { mls_group: MlsGroup, convo_id: String, @@ -196,6 +198,9 @@ impl GroupV1Convo { // Hash and Cache to detect inbound messages let msg_hash = blake2b_hex::(&[&msg_bytes]); self.outbound_msgs.push_back(msg_hash); + if self.outbound_msgs.len() > OUTBOUND_HASH_CACHE_SIZE { + let _ = self.outbound_msgs.remove(0); + } // Wrap in Payload frames let aep = AddressedEncryptedPayload { @@ -211,7 +216,7 @@ impl GroupV1Convo { // Send via DS cx.ds .publish(env) - .map_err(|e| ChatError::Generic(format!("Publish: {e}"))) + .map_err(|e| ChatError::Delivery(e.to_string())) } } diff --git a/crates/client/examples/message-exchange/main.rs b/crates/client/examples/message-exchange/main.rs index 33f8e2a..ea755d5 100644 --- a/crates/client/examples/message-exchange/main.rs +++ b/crates/client/examples/message-exchange/main.rs @@ -30,7 +30,10 @@ fn main() { if let Event::MessageReceived { content, .. } = raya_events.recv_timeout(Duration::from_secs(5)).unwrap() { - println!("Raya received: {:?}", std::str::from_utf8(&content).unwrap()); + println!( + "Raya received: {:?}", + std::str::from_utf8(&content).unwrap() + ); } raya.send_message(&raya_convo_id, b"hi saro").unwrap(); @@ -38,7 +41,10 @@ fn main() { if let Event::MessageReceived { content, .. } = saro_events.recv_timeout(Duration::from_secs(5)).unwrap() { - println!("Saro received: {:?}", std::str::from_utf8(&content).unwrap()); + println!( + "Saro received: {:?}", + std::str::from_utf8(&content).unwrap() + ); } println!("Message exchange complete."); diff --git a/crates/client/tests/saro_and_raya.rs b/crates/client/tests/saro_and_raya.rs index b9dfa87..6eb4042 100644 --- a/crates/client/tests/saro_and_raya.rs +++ b/crates/client/tests/saro_and_raya.rs @@ -261,29 +261,6 @@ fn dropping_client_shuts_down_worker() { )); } -#[test] -fn publish_failure_surfaces_as_error() { - // A real raya just to mint a valid intro bundle. - let (mut saro, _events) = - create_test_client(MessageBus::default(), EphemeralRegistry::new()).expect("client create"); - - // FailingDelivery never receives; keep the inbound sender alive so the - // worker doesn't exit early on a disconnected channel. - let delivery = FailingDelivery::new(); - let _keep_inbound = delivery.inbound_sender(); - - let (raya, _raya_events) = ChatClientBuilder::new() - .transport(delivery) - .build() - .expect("create client"); - let result = saro.create_direct_conversation(raya.addr()); - - assert!( - result.is_err(), - "publish failure should surface as an error on the synchronous call" - ); -} - #[test] fn malformed_inbound_surfaces_as_error_event() { // Feed the worker's inbound channel bytes that can't be decoded and assert