mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-05-12 21:19:44 +00:00
Wrap constructor in result
This commit is contained in:
parent
60e728576a
commit
da7e06e495
@ -78,7 +78,7 @@ where
|
|||||||
ctx: Rc<RefCell<MlsCtx>>,
|
ctx: Rc<RefCell<MlsCtx>>,
|
||||||
ds: Rc<RefCell<DS>>,
|
ds: Rc<RefCell<DS>>,
|
||||||
keypkg_provider: Rc<RefCell<KP>>,
|
keypkg_provider: Rc<RefCell<KP>>,
|
||||||
) -> Self {
|
) -> Result<Self, ChatError> {
|
||||||
let config = Self::mls_create_config();
|
let config = Self::mls_create_config();
|
||||||
let mls_group = {
|
let mls_group = {
|
||||||
let ctx_ref = ctx.borrow();
|
let ctx_ref = ctx.borrow();
|
||||||
@ -91,7 +91,7 @@ where
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
let convo_id = hex::encode(mls_group.group_id().as_slice());
|
let convo_id = hex::encode(mls_group.group_id().as_slice());
|
||||||
Self::subscribe(&mut ds.borrow_mut(), &convo_id);
|
Self::subscribe(&mut ds.borrow_mut(), &convo_id)?;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"@ Create Convo: {}. {}. d:{} dc:{}",
|
"@ Create Convo: {}. {}. d:{} dc:{}",
|
||||||
@ -100,13 +100,13 @@ where
|
|||||||
Self::delivery_address_from_id(&convo_id),
|
Self::delivery_address_from_id(&convo_id),
|
||||||
Self::ctrl_delivery_address_from_id(&convo_id)
|
Self::ctrl_delivery_address_from_id(&convo_id)
|
||||||
);
|
);
|
||||||
Self {
|
Ok(Self {
|
||||||
ctx,
|
ctx,
|
||||||
ds,
|
ds,
|
||||||
keypkg_provider,
|
keypkg_provider,
|
||||||
mls_group,
|
mls_group,
|
||||||
convo_id,
|
convo_id,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_welcome(
|
pub fn new_from_welcome(
|
||||||
@ -114,7 +114,7 @@ where
|
|||||||
ds: Rc<RefCell<DS>>,
|
ds: Rc<RefCell<DS>>,
|
||||||
keypkg_provider: Rc<RefCell<KP>>,
|
keypkg_provider: Rc<RefCell<KP>>,
|
||||||
welcome: Welcome,
|
welcome: Welcome,
|
||||||
) -> Self {
|
) -> Result<Self, ChatError> {
|
||||||
let mls_group = {
|
let mls_group = {
|
||||||
let ctx_borrow = ctx.borrow();
|
let ctx_borrow = ctx.borrow();
|
||||||
let provider = ctx_borrow.provider();
|
let provider = ctx_borrow.provider();
|
||||||
@ -128,7 +128,7 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
let convo_id = hex::encode(mls_group.group_id().as_slice());
|
let convo_id = hex::encode(mls_group.group_id().as_slice());
|
||||||
Self::subscribe(&mut *ds.borrow_mut(), &convo_id);
|
Self::subscribe(&mut *ds.borrow_mut(), &convo_id)?;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"@ Welcome Convo: I:{}. {}. d:{} dc:{}",
|
"@ Welcome Convo: I:{}. {}. d:{} dc:{}",
|
||||||
@ -138,13 +138,13 @@ where
|
|||||||
Self::ctrl_delivery_address_from_id(&convo_id)
|
Self::ctrl_delivery_address_from_id(&convo_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
GroupV1Convo {
|
Ok(Self {
|
||||||
ctx,
|
ctx,
|
||||||
ds,
|
ds,
|
||||||
keypkg_provider,
|
keypkg_provider,
|
||||||
mls_group,
|
mls_group,
|
||||||
convo_id,
|
convo_id,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load(
|
pub fn load(
|
||||||
|
|||||||
@ -141,8 +141,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_group_v1(&self) -> Result<GroupV1Convo<PqMlsContext, DS, RS>, ChatError> {
|
pub fn create_group_v1(&self) -> Result<GroupV1Convo<PqMlsContext, DS, RS>, ChatError> {
|
||||||
let convo = GroupV1Convo::new(self.ctx.clone(), self.ds.clone(), self.reg_service.clone());
|
GroupV1Convo::new(self.ctx.clone(), self.ds.clone(), self.reg_service.clone())
|
||||||
Ok(convo)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_frame(&self, payload_bytes: &[u8]) -> Result<(), ChatError> {
|
pub fn handle_frame(&self, payload_bytes: &[u8]) -> Result<(), ChatError> {
|
||||||
@ -187,7 +186,7 @@ where
|
|||||||
self.ds.clone(),
|
self.ds.clone(),
|
||||||
self.reg_service.clone(),
|
self.reg_service.clone(),
|
||||||
welcome,
|
welcome,
|
||||||
);
|
)?;
|
||||||
self.persist_convo(convo)
|
self.persist_convo(convo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user