mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-08-04 06:03:12 +00:00
Rename to DirectV1
This commit is contained in:
parent
93c465ef8d
commit
83f8fb4371
@ -2,7 +2,6 @@ mod direct_v1;
|
|||||||
pub mod group_v1;
|
pub mod group_v1;
|
||||||
mod group_v2;
|
mod group_v2;
|
||||||
mod privatev1;
|
mod privatev1;
|
||||||
mod privatev2;
|
|
||||||
|
|
||||||
pub use crate::errors::ChatError;
|
pub use crate::errors::ChatError;
|
||||||
use crate::outcomes::ConvoOutcome;
|
use crate::outcomes::ConvoOutcome;
|
||||||
@ -12,7 +11,6 @@ pub use direct_v1::DirectV1Convo;
|
|||||||
pub use group_v1::GroupV1Convo;
|
pub use group_v1::GroupV1Convo;
|
||||||
pub use group_v2::GroupV2Convo;
|
pub use group_v2::GroupV2Convo;
|
||||||
pub use privatev1::PrivateV1Convo;
|
pub use privatev1::PrivateV1Convo;
|
||||||
pub use privatev2::PrivateV2Convo;
|
|
||||||
use shared_traits::IdentIdRef;
|
use shared_traits::IdentIdRef;
|
||||||
|
|
||||||
pub type ConversationId = String;
|
pub type ConversationId = String;
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
use chat_proto::logoschat::encryption::EncryptedPayload;
|
|
||||||
use shared_traits::IdentIdRef;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
ChatError, ExternalServices,
|
|
||||||
conversation::{ConversationIdRef, Convo, GroupConvo, GroupV1Convo, Identified},
|
|
||||||
service_context::ServiceContext,
|
|
||||||
};
|
|
||||||
|
|
||||||
type DelegateGroup = GroupV1Convo;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct PrivateV2Convo {
|
|
||||||
inner_group: DelegateGroup,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PrivateV2Convo {
|
|
||||||
pub fn new<S: ExternalServices>(
|
|
||||||
cx: &mut ServiceContext<S>,
|
|
||||||
participant: IdentIdRef,
|
|
||||||
) -> Result<Self, ChatError> {
|
|
||||||
let mut inner_group = DelegateGroup::new(cx)?;
|
|
||||||
inner_group.add_member(cx, &[participant])?;
|
|
||||||
Ok(Self { inner_group })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Identified for PrivateV2Convo {
|
|
||||||
fn id(&self) -> ConversationIdRef<'_> {
|
|
||||||
self.inner_group.id()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S> Convo<S> for PrivateV2Convo
|
|
||||||
where
|
|
||||||
S: ExternalServices,
|
|
||||||
{
|
|
||||||
fn send_content(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut ServiceContext<S>,
|
|
||||||
content: &[u8],
|
|
||||||
) -> Result<(), super::ChatError> {
|
|
||||||
self.inner_group.send_content(cx, content)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_frame(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut ServiceContext<S>,
|
|
||||||
enc: EncryptedPayload,
|
|
||||||
) -> Result<crate::ConvoOutcome, ChatError> {
|
|
||||||
self.inner_group.handle_frame(cx, enc)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wakeup(&mut self, service_ctx: &mut ServiceContext<S>) -> Result<(), ChatError> {
|
|
||||||
self.inner_group.wakeup(service_ctx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
use integration_tests_core::TestHarness;
|
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn happypath_roundtrip() {
|
|
||||||
let _ = tracing_subscriber::fmt()
|
|
||||||
.with_max_level(tracing::Level::INFO)
|
|
||||||
.with_test_writer()
|
|
||||||
.try_init();
|
|
||||||
|
|
||||||
const S_M1: &[u8] = b"Marco";
|
|
||||||
const R_M1: &[u8] = b"Polo";
|
|
||||||
|
|
||||||
// Initialize TestHarness with 2 clients
|
|
||||||
let mut harness = TestHarness::<2>::new(|_, _| {});
|
|
||||||
|
|
||||||
//Saro Create Convo
|
|
||||||
let particpant = harness.raya().addr();
|
|
||||||
let convo_id = harness
|
|
||||||
.saro()
|
|
||||||
.create_direct_convo_v1(&[&particpant])
|
|
||||||
.expect("saro create group");
|
|
||||||
|
|
||||||
// Carry the invite through (commit, WelcomeReady, routing to Raya's inbox,
|
|
||||||
// accept_welcome); settle until Raya has joined.
|
|
||||||
harness.process_until_label("Saro Send", |h| h.raya().convo_count() == 1);
|
|
||||||
|
|
||||||
// Saro sends a message; settle until Raya receives it.
|
|
||||||
info!(target: "chat", "Saro -> sending: {S_M1:?}");
|
|
||||||
harness
|
|
||||||
.saro()
|
|
||||||
.send_content(&convo_id, S_M1)
|
|
||||||
.expect("saro send");
|
|
||||||
|
|
||||||
harness.process_until(|h| h.raya().check(&convo_id, S_M1));
|
|
||||||
|
|
||||||
// Raya replies; settle until Saro receives it.
|
|
||||||
info!(target: "chat", "Raya -> sending:{R_M1:?}");
|
|
||||||
harness.raya().send_content(&convo_id, R_M1).unwrap();
|
|
||||||
harness.process_until(|h| h.saro().check(&convo_id, R_M1));
|
|
||||||
|
|
||||||
assert!(harness.saro().check(&convo_id, R_M1));
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user