mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-06-30 21:20:09 +00:00
Update DirectV1 to support multiple members
This commit is contained in:
parent
065b37b1e7
commit
206314bbef
@ -9,18 +9,23 @@ use crate::{
|
|||||||
|
|
||||||
type DelegateGroup = GroupV1Convo;
|
type DelegateGroup = GroupV1Convo;
|
||||||
|
|
||||||
|
/// A Conversation between two participants.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DirectV1Convo {
|
pub struct DirectV1Convo {
|
||||||
inner_group: DelegateGroup,
|
inner_group: DelegateGroup,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DirectV1Convo {
|
impl DirectV1Convo {
|
||||||
|
// Constructor must accept multiple IdentId's
|
||||||
|
// While the conversation is limited to 2 participants, each participants may
|
||||||
|
// have multiple Installations.
|
||||||
pub fn new<S: ExternalServices>(
|
pub fn new<S: ExternalServices>(
|
||||||
cx: &mut ServiceContext<S>,
|
cx: &mut ServiceContext<S>,
|
||||||
participant: IdentIdRef,
|
// Constructor must accept multiple
|
||||||
|
members: &[IdentIdRef],
|
||||||
) -> Result<Self, ChatError> {
|
) -> Result<Self, ChatError> {
|
||||||
let mut inner_group = DelegateGroup::new(cx)?;
|
let mut inner_group = DelegateGroup::new(cx)?;
|
||||||
inner_group.add_member(cx, &[participant])?;
|
inner_group.add_member(cx, members)?;
|
||||||
Ok(Self { inner_group })
|
Ok(Self { inner_group })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -215,9 +215,9 @@ impl<'a, S: ExternalServices + 'static> Core<S> {
|
|||||||
|
|
||||||
pub fn create_direct_convo_v1(
|
pub fn create_direct_convo_v1(
|
||||||
&mut self,
|
&mut self,
|
||||||
pariticpant: IdentIdRef,
|
members: &[IdentIdRef],
|
||||||
) -> Result<ConversationId, ChatError> {
|
) -> Result<ConversationId, ChatError> {
|
||||||
let convo = DirectV1Convo::new(&mut self.services, pariticpant)?;
|
let convo = DirectV1Convo::new(&mut self.services, members)?;
|
||||||
let convo_id = convo.id().to_string();
|
let convo_id = convo.id().to_string();
|
||||||
self.register_convo(ConvoTypeOwned::Direct(Box::new(convo)))?;
|
self.register_convo(ConvoTypeOwned::Direct(Box::new(convo)))?;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user