mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-07-09 09:29:39 +00:00
Update config
This commit is contained in:
parent
4287f2e4f7
commit
8997957639
@ -2,6 +2,9 @@
|
|||||||
// DeMLS and Libchat have different execution models, trait definitions and ownership/lifetimes of objects.
|
// DeMLS and Libchat have different execution models, trait definitions and ownership/lifetimes of objects.
|
||||||
// The easies path is to do a Spike to see what it would take, gather the friction points and then iterate.
|
// The easies path is to do a Spike to see what it would take, gather the friction points and then iterate.
|
||||||
|
|
||||||
|
use crate::conversation::mls_extensions::{
|
||||||
|
ConvoMetaInfo, GROUP_METADATA_EXTENSION_TYPE, capabilities_with_group_metadata,
|
||||||
|
};
|
||||||
use crate::types::{AddressedEncryptedPayload, ConvoMetadata};
|
use crate::types::{AddressedEncryptedPayload, ConvoMetadata};
|
||||||
use crate::{Content, WakeupService};
|
use crate::{Content, WakeupService};
|
||||||
use alloy::signers::local::PrivateKeySigner;
|
use alloy::signers::local::PrivateKeySigner;
|
||||||
@ -16,9 +19,11 @@ use de_mls::{
|
|||||||
defaults::{DefaultConsensusPlugin, DefaultPeerScoring, InMemoryPeerScoreStorage},
|
defaults::{DefaultConsensusPlugin, DefaultPeerScoring, InMemoryPeerScoreStorage},
|
||||||
};
|
};
|
||||||
use hashgraph_like_consensus::signing::EthereumConsensusSigner;
|
use hashgraph_like_consensus::signing::EthereumConsensusSigner;
|
||||||
|
use openmls::extensions::{Extension, Extensions, UnknownExtension};
|
||||||
use openmls::group::MlsGroupCreateConfig;
|
use openmls::group::MlsGroupCreateConfig;
|
||||||
use openmls::prelude::tls_codec::Deserialize as _;
|
use openmls::prelude::tls_codec::Deserialize as _;
|
||||||
use openmls::prelude::{KeyPackageIn, OpenMlsProvider as _, ProtocolVersion};
|
use openmls::prelude::{KeyPackageIn, OpenMlsProvider as _, ProtocolVersion};
|
||||||
|
use openmls_traits::crypto::OpenMlsCrypto;
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
use shared_traits::{IdentId, IdentIdRef};
|
use shared_traits::{IdentId, IdentIdRef};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -95,23 +100,41 @@ fn rand_string(n: usize) -> String {
|
|||||||
hex::encode(bytes)
|
hex::encode(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn group_config() -> MlsGroupCreateConfig {
|
fn group_config<S: ExternalServices>(
|
||||||
|
cx: &mut ServiceContext<S>,
|
||||||
|
name: &str,
|
||||||
|
desc: &str,
|
||||||
|
) -> MlsGroupCreateConfig {
|
||||||
|
let meta = ConvoMetaInfo::new(name, cx.mls_identity.id(), desc);
|
||||||
|
|
||||||
|
let extensions = Extensions::from_vec(vec![Extension::Unknown(
|
||||||
|
GROUP_METADATA_EXTENSION_TYPE,
|
||||||
|
UnknownExtension(meta.to_extension_bytes()),
|
||||||
|
)])
|
||||||
|
.expect("failed to create extensions");
|
||||||
|
|
||||||
MlsGroupCreateConfig::builder()
|
MlsGroupCreateConfig::builder()
|
||||||
.use_ratchet_tree_extension(true)
|
.ciphersuite(cx.mls_provider.crypto().supported_ciphersuites()[0])
|
||||||
|
.capabilities(capabilities_with_group_metadata())
|
||||||
|
.use_ratchet_tree_extension(true) // Embed the ratchet tree in the Welcome so joiners can build the group
|
||||||
|
.with_group_context_extensions(extensions)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GroupV2Convo {
|
impl GroupV2Convo {
|
||||||
pub fn new<S: ExternalServices>(
|
pub fn new<S: ExternalServices>(
|
||||||
service_ctx: &mut ServiceContext<S>,
|
service_ctx: &mut ServiceContext<S>,
|
||||||
|
name: &str,
|
||||||
|
desc: &str,
|
||||||
) -> Result<Self, ChatError> {
|
) -> Result<Self, ChatError> {
|
||||||
let convo_id = rand_string(5);
|
let convo_id = rand_string(5);
|
||||||
|
let group_config = group_config(service_ctx, name, desc);
|
||||||
let conversation = Conversation::create(
|
let conversation = Conversation::create(
|
||||||
&convo_id,
|
&convo_id,
|
||||||
&member_id(service_ctx),
|
&member_id(service_ctx),
|
||||||
&service_ctx.mls_provider,
|
&service_ctx.mls_provider,
|
||||||
service_ctx.mls_identity.get_credential(),
|
service_ctx.mls_identity.get_credential(),
|
||||||
&group_config(),
|
&group_config,
|
||||||
&service_ctx.mls_identity,
|
&service_ctx.mls_identity,
|
||||||
&make_consensus(),
|
&make_consensus(),
|
||||||
make_scoring(),
|
make_scoring(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user