From d17369018695203adb1f07ad9b0c213c4977bcde Mon Sep 17 00:00:00 2001 From: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com> Date: Thu, 22 Jan 2026 18:04:31 -0800 Subject: [PATCH] Move to Payload data --- conversations/src/context.rs | 6 ++---- conversations/src/inbox/inbox.rs | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/conversations/src/context.rs b/conversations/src/context.rs index 393b6c3..e40f97c 100644 --- a/conversations/src/context.rs +++ b/conversations/src/context.rs @@ -1,6 +1,4 @@ -use std::rc::Rc; - -use crypto::PrekeyBundle; +use std::{collections::HashMap, rc::Rc, sync::Arc}; use crate::{ conversation::{ConversationId, ConversationIdOwned, ConversationStore}, @@ -34,7 +32,7 @@ impl Context { &mut self, remote_bundle: &Introduction, content: String, - ) -> (ConversationIdOwned, Vec) { + ) -> (ConversationIdOwned, Vec) { let (convo, payloads) = self .inbox .invite_to_private_convo(remote_bundle, content) diff --git a/conversations/src/inbox/inbox.rs b/conversations/src/inbox/inbox.rs index 73382d7..c157dde 100644 --- a/conversations/src/inbox/inbox.rs +++ b/conversations/src/inbox/inbox.rs @@ -14,7 +14,7 @@ use crate::crypto::{Blake2b128, CopyBytes, Digest, PublicKey, StaticSecret}; use crate::identity::Identity; use crate::inbox::handshake::InboxHandshake; use crate::proto::{self}; -use crate::types::ContentData; +use crate::types::{ContentData, PayloadData}; pub struct Inbox { ident: Rc, @@ -69,7 +69,7 @@ impl Inbox { &self, remote_bundle: &Introduction, initial_message: String, - ) -> Result<(PrivateV1Convo, Vec), ChatError> { + ) -> Result<(PrivateV1Convo, Vec), ChatError> { let mut rng = OsRng; // TODO: Include signature in introduction bundle. Manaully fill for now @@ -112,7 +112,15 @@ impl Inbox { }; } - Ok((convo, initial_payloads)) + let payload_data = initial_payloads + .iter() + .map(|p| PayloadData { + delivery_address: "delivery_address".into(), + data: p.encode_to_vec(), + }) + .collect(); + + Ok((convo, payload_data)) } fn wrap_in_invite(payload: proto::EncryptedPayload) -> proto::InboxV1Frame { @@ -238,12 +246,12 @@ mod tests { .invite_to_private_convo(&bundle.into(), "hello".into()) .unwrap(); - let encrypted_payload = payloads + let payload = payloads .get(0) .expect("RemoteInbox::invite_to_private_convo did not generate any payloads"); let mut buf = Vec::new(); - encrypted_payload.encode(&mut buf).unwrap(); + payload.data.encode(&mut buf).unwrap(); // Test handle_frame with valid payload let result = raya_inbox.handle_frame(&buf);