mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-06-28 03:59:27 +00:00
Invite PAX after Raya has been added
This commit is contained in:
parent
b9db79a7c1
commit
a9334e4142
@ -48,6 +48,11 @@ where
|
||||
let mut client = self.client.borrow_mut();
|
||||
client.send_content(self.convo_id.as_str(), content)
|
||||
}
|
||||
|
||||
pub fn add_member(&self, participants: &[&AccountId]) -> Result<(), ChatError> {
|
||||
let mut client = self.client.borrow_mut();
|
||||
client.add_member(&self.convo_id, participants)
|
||||
}
|
||||
}
|
||||
|
||||
// This allows the ExternalServices trait to be converted from a tuple.
|
||||
@ -266,6 +271,22 @@ where
|
||||
convo.send_content(&mut self.service_ctx, content)
|
||||
}
|
||||
|
||||
pub fn add_member(
|
||||
&mut self,
|
||||
convo_id: ConversationIdRef,
|
||||
members: &[&AccountId],
|
||||
) -> Result<(), ChatError> {
|
||||
let Some(convo) = self.cached_convos.get_mut(convo_id) else {
|
||||
return Err(ChatError::generic("No Convo Found"));
|
||||
};
|
||||
let convo = match convo {
|
||||
// ConvoTypeOwned::Pairwise(_) => todo!(),
|
||||
ConvoTypeOwned::Group(c) => c.as_mut(),
|
||||
};
|
||||
|
||||
convo.add_member(&mut self.service_ctx, members)
|
||||
}
|
||||
|
||||
// Decode bytes and send to protocol for processing.
|
||||
pub fn handle_payload(&mut self, payload: &[u8]) -> Result<Option<ContentData>, ChatError> {
|
||||
let env = EnvelopeV1::decode(payload)?;
|
||||
|
||||
@ -272,7 +272,11 @@ fn wakup() {
|
||||
|
||||
#[test]
|
||||
fn core_client() {
|
||||
// let _ = tracing_subscriber::fmt().with_test_writer().try_init();
|
||||
// Test Toggle:
|
||||
// If Raya Invites PAX, The Welcome is not sent, and Pax does not join the conversation.
|
||||
// If Saro does everything works
|
||||
const RAYA_INVITE: bool = false;
|
||||
|
||||
let _ = tracing_subscriber::fmt()
|
||||
.with_max_level(tracing::Level::INFO)
|
||||
.with_test_writer()
|
||||
@ -330,10 +334,10 @@ fn core_client() {
|
||||
const RAYA: usize = 1;
|
||||
const PAX: usize = 2;
|
||||
|
||||
let s_convo = clients[SARO]
|
||||
.create_group_convo(&[&clients[RAYA].account_id(), &clients[PAX].account_id()])
|
||||
let wait_time_ms: u32 = 400;
|
||||
|
||||
let saro_convo = clients[SARO]
|
||||
.create_group_convo(&[&clients[RAYA].account_id()])
|
||||
.unwrap();
|
||||
|
||||
// Bounded driver: de-mls reschedules its steward poll every tick, so a
|
||||
@ -356,7 +360,7 @@ fn core_client() {
|
||||
// Saro sends a message; Raya receives it (look for "Raya received: HI"
|
||||
// in the log).
|
||||
info!(target: "chat", "Saro -> sending: HI");
|
||||
s_convo.send_content(b"HI").unwrap();
|
||||
saro_convo.send_content(b"HI").unwrap();
|
||||
process(&mut clients, &mut wakeups, wait_time_ms);
|
||||
|
||||
// Raya replies; Saro receives it (look for "Saro received: hi back").
|
||||
@ -366,4 +370,25 @@ fn core_client() {
|
||||
info!(target: "chat", "Raya -> sending: hi back");
|
||||
raya_convo.send_content(b"hi back").unwrap();
|
||||
process(&mut clients, &mut wakeups, wait_time_ms);
|
||||
|
||||
if RAYA_INVITE {
|
||||
&raya_convo
|
||||
} else {
|
||||
&saro_convo
|
||||
}
|
||||
.add_member(&[&clients[PAX].account_id()])
|
||||
.unwrap();
|
||||
|
||||
process(&mut clients, &mut wakeups, wait_time_ms);
|
||||
process(&mut clients, &mut wakeups, wait_time_ms);
|
||||
process(&mut clients, &mut wakeups, wait_time_ms);
|
||||
|
||||
let pax_convos = clients[PAX].list_conversations().unwrap();
|
||||
let pax_convo = clients[PAX]
|
||||
.convo(&pax_convos[0])
|
||||
.expect("PAX must have a usable conversation handle");
|
||||
info!(target: "chat", "Pax -> sending: hi back");
|
||||
raya_convo.send_content(b"hi yall").unwrap();
|
||||
pax_convo.send_content(b"Hey I'm PAX").unwrap();
|
||||
process(&mut clients, &mut wakeups, wait_time_ms);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user