From 982a536ea5103794003400ba3909de01b63ebd39 Mon Sep 17 00:00:00 2001 From: Mojtaba Chenani Date: Wed, 19 Aug 2026 11:44:05 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20expose=20ConversationClass=20(serde=20d?= =?UTF-8?q?erive=20+=20rename=20Private=E2=86=92Dm)=20(#214)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 1 + core/conversations/Cargo.toml | 1 + core/conversations/src/inbox_v2.rs | 4 ++-- core/conversations/src/outcomes.rs | 5 +++-- crates/generic-chat/tests/saro_and_raya.rs | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c93bad7..0ed89c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3359,6 +3359,7 @@ dependencies = [ "prost", "rand 0.9.4", "rand_core 0.6.4", + "serde", "shared-traits", "storage", "tempfile", diff --git a/core/conversations/Cargo.toml b/core/conversations/Cargo.toml index 61742b5..0742a7a 100644 --- a/core/conversations/Cargo.toml +++ b/core/conversations/Cargo.toml @@ -30,6 +30,7 @@ openmls_traits = "0.5.0" prost = "0.14.1" rand = "0.9" rand_core = { version = "0.6" } +serde = { version = "1.0", features = ["derive"] } thiserror = "2.0.17" tracing = "0.1.44" x25519-dalek = { version = "2.0.1", features = [ diff --git a/core/conversations/src/inbox_v2.rs b/core/conversations/src/inbox_v2.rs index ead4575..46ec59a 100644 --- a/core/conversations/src/inbox_v2.rs +++ b/core/conversations/src/inbox_v2.rs @@ -122,7 +122,7 @@ impl InboxV2 { /// The convo built from an invite, paired with the display class its invite /// type implies: `InviteType::GroupV1` carries the pairwise DirectV1 welcome, - /// so it is `Private`; `InviteType::GroupV2` is a real group. + /// so it is `Dm`; `InviteType::GroupV2` is a real group. #[instrument(name = "inboxV2.handle_frame", skip_all, fields(user_id = %service_ctx.mls_identity.display_name()))] pub fn handle_frame( &self, @@ -143,7 +143,7 @@ impl InboxV2 { match payload { InviteType::GroupV1(inv) => { let convo = self.handle_heavy_invite(service_ctx, inv)?; - Ok(Some((Box::new(convo), ConversationClass::Private))) + Ok(Some((Box::new(convo), ConversationClass::Dm))) } InviteType::GroupV2(welcome_bytes) => { info!("Process WelcomeMessage"); diff --git a/core/conversations/src/outcomes.rs b/core/conversations/src/outcomes.rs index 18877e7..78221fb 100644 --- a/core/conversations/src/outcomes.rs +++ b/core/conversations/src/outcomes.rs @@ -6,6 +6,7 @@ //! initial [`ConvoOutcome`]. //! - [`PayloadOutcome`] — the union of the above, plus `Empty`. +use serde::{Deserialize, Serialize}; use storage::ConversationKind; use crate::conversation::ConversationId; @@ -68,9 +69,9 @@ impl From for PayloadOutcome { } /// Stable across protocol versions of the same conversation shape. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum ConversationClass { - Private, + Dm, Group, } diff --git a/crates/generic-chat/tests/saro_and_raya.rs b/crates/generic-chat/tests/saro_and_raya.rs index 09f3ae7..e45f660 100644 --- a/crates/generic-chat/tests/saro_and_raya.rs +++ b/crates/generic-chat/tests/saro_and_raya.rs @@ -189,7 +189,7 @@ fn direct_v1_by_account_address() { // though its welcome rides the InboxV2 (GroupV1 invite) path. let raya_convo_id = expect_event(&raya_events, "ConversationStarted", |e| match e { Event::ConversationStarted { convo_id, class } => { - assert_eq!(class, ConversationClass::Private); + assert_eq!(class, ConversationClass::Dm); Ok(convo_id) } other => Err(other),