From a27dfb1a7fdb41e0f5ac8d4879d37287b4e2bbf2 Mon Sep 17 00:00:00 2001 From: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com> Date: Thu, 18 Jun 2026 17:26:43 -0700 Subject: [PATCH] Add client path for DirectConvo --- .../src/conversation/direct_v1.rs | 4 --- core/conversations/src/core.rs | 7 ++--- crates/client/src/client.rs | 31 +++++++++++++++++-- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/core/conversations/src/conversation/direct_v1.rs b/core/conversations/src/conversation/direct_v1.rs index e40c36c..f75bdb0 100644 --- a/core/conversations/src/conversation/direct_v1.rs +++ b/core/conversations/src/conversation/direct_v1.rs @@ -21,10 +21,6 @@ impl DirectV1Convo { // have multiple Installations. pub fn new( cx: &mut ServiceContext, -<<<<<<< HEAD -======= - // Constructor must accept multiple ->>>>>>> 206314b (Update DirectV1 to support multiple members) members: &[IdentIdRef], ) -> Result { let mut inner_group = DelegateGroup::new(cx)?; diff --git a/core/conversations/src/core.rs b/core/conversations/src/core.rs index d88a4a8..37fbe71 100644 --- a/core/conversations/src/core.rs +++ b/core/conversations/src/core.rs @@ -185,12 +185,11 @@ impl<'a, S: ExternalServices + 'static> Core { self.services.identity.public_key() } - pub fn create_private_convo( + pub fn create_direct_convo( &mut self, - remote_bundle: &Introduction, - content: &[u8], + members: &[IdentIdRef], ) -> Result { - self.create_private_convo_v1(remote_bundle, content) + self.create_direct_convo_v1(members) } pub fn create_private_convo_v1( diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 170030a..4337bf9 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -4,8 +4,8 @@ use std::thread::{self, JoinHandle}; use components::{EphemeralRegistry, ThreadedWakeupService, WakeupEvent}; use crossbeam_channel::{Receiver, Sender, select}; use libchat::{ - ChatError, ChatStorage, ConversationId, ConvoOutcome, Core, DeliveryService, InboxOutcome, - Introduction, PayloadOutcome, RegistrationService, StorageConfig, + ChatError, ChatStorage, ConversationId, ConvoOutcome, Core, DeliveryService, IdentId, + IdentIdRef, InboxOutcome, Introduction, PayloadOutcome, RegistrationService, StorageConfig, }; use logos_account::TestLogosAccount; use parking_lot::Mutex; @@ -14,6 +14,8 @@ use crate::errors::ClientError; use crate::event::Event; type ClientCore = Core<(TestLogosAccount, T, R, ThreadedWakeupService, ChatStorage)>; +type AccountAddressRef<'a> = &'a str; +type LocalSignerId = IdentId; /// The transport as the client sees it: a [`DeliveryService`] for outbound /// publishing plus the inbound payload stream the worker drains. One object owns @@ -158,8 +160,24 @@ where self.core.lock().create_intro_bundle().map_err(Into::into) } + // Creates a conversation between two Accounts. + pub fn create_direct_conversation( + &mut self, + account: AccountAddressRef, + ) -> Result { + let signers = self.signers_from_account(account)?; + let signer_refs: Vec = signers.iter().collect(); + + self.core + .lock() + .create_direct_convo(&signer_refs) + .map_err(Into::into) + } + /// Parse intro bundle bytes and initiate a private conversation. Outbound /// envelopes are published by the core. Returns this side's conversation ID. + /// + /// This function will be deprecated in the future. Use `create_direct_conversation` pub fn create_conversation( &mut self, intro_bundle: &[u8], @@ -185,6 +203,15 @@ where .send_content(convo_id, content) .map_err(Into::into) } + + // Get signers for a given AccountAddress. + fn signers_from_account( + &self, + account: AccountAddressRef, + ) -> Result, ClientError> { + // Assume Account = LocalSigner until Account is ready + Ok(vec![IdentId::new(account.to_string())]) + } } impl Drop for ChatClient {