diff --git a/xmtp_mls/src/groups/mod.rs b/xmtp_mls/src/groups/mod.rs index 837523442..80f9c5025 100644 --- a/xmtp_mls/src/groups/mod.rs +++ b/xmtp_mls/src/groups/mod.rs @@ -15,11 +15,12 @@ use openmls::{ UnknownExtension, }, group::{ - CommitToPendingProposalsError, MlsGroupCreateConfig, MlsGroupJoinConfig, ProposalError, + CommitToPendingProposalsError, MergePendingCommitError, MlsGroupCreateConfig, + MlsGroupJoinConfig, ProposalError, }, prelude::{ - CredentialWithKey, CryptoConfig, Error as TlsCodecError, GroupId, MlsGroup as OpenMlsGroup, - StagedWelcome, Welcome as MlsWelcome, WireFormatPolicy, + Capabilities, CredentialWithKey, CryptoConfig, Error as TlsCodecError, GroupId, + MlsGroup as OpenMlsGroup, StagedWelcome, Welcome as MlsWelcome, WireFormatPolicy, }, }; use openmls_traits::OpenMlsProvider; @@ -140,6 +141,8 @@ pub enum GroupError { ProposalError(#[from] ProposalError<()>), #[error("commit to pending proposal error: {0}")] CommitToPendingProposalsError(#[from] CommitToPendingProposalsError), + #[error("merge pending commit error: {0}")] + MergePendingCommitError(#[from] MergePendingCommitError), } impl RetryableError for GroupError { @@ -533,18 +536,30 @@ fn build_group_config( protected_metadata_extension: Extension, mutable_metadata_extension: Extension, ) -> Result { - let mut extensions = Extensions::single(protected_metadata_extension); - extensions.add(mutable_metadata_extension)?; - - let rc_extensions = &[ExtensionType::Unknown(0xff11)]; + let required_extension_types = &[ + ExtensionType::Unknown(0xff11), + ExtensionType::ImmutableMetadata, + ExtensionType::LastResort, + ExtensionType::ApplicationId, + ]; + + let capabilities = Capabilities::new(None, None, Some(required_extension_types), None, None); let proposals = &[]; let credentials = &[CredentialType::Basic]; - let required_capabilities = - RequiredCapabilitiesExtension::new(rc_extensions, proposals, credentials); - let _ = extensions.add(Extension::RequiredCapabilities(required_capabilities))?; + let required_capabilities = Extension::RequiredCapabilities( + RequiredCapabilitiesExtension::new(required_extension_types, proposals, credentials), + ); + + let extensions = Extensions::from_vec(vec![ + protected_metadata_extension, + mutable_metadata_extension, + required_capabilities, + ])?; + Ok(MlsGroupCreateConfig::builder() .with_group_context_extensions(extensions)? + .capabilities(capabilities) .crypto_config(CryptoConfig::with_default_version(CIPHERSUITE)) .wire_format_policy(WireFormatPolicy::default()) .max_past_epochs(3) // Trying with 3 max past epochs for now diff --git a/xmtp_mls/src/groups/sync.rs b/xmtp_mls/src/groups/sync.rs index cacbe2ed9..a243e669c 100644 --- a/xmtp_mls/src/groups/sync.rs +++ b/xmtp_mls/src/groups/sync.rs @@ -34,6 +34,7 @@ use super::{ intents::{ AddMembersIntentData, AddressesOrInstallationIds, Installation, PostCommitAction, RemoveMembersIntentData, SendMessageIntentData, SendWelcomesAction, + UpdateMetadataIntentData, }, members::GroupMember, GroupError, MlsGroup, @@ -659,8 +660,9 @@ where Ok((commit.tls_serialize_detached()?, None)) } IntentKind::MetadataUpdate => { + let metadata_intent = UpdateMetadataIntentData::from_bytes(intent.data.as_slice())?; let mutable_metadata = build_mutable_metadata_extension( - "New Group".to_string(), + metadata_intent.group_name, vec![self.client.account_address().clone()], )?; let mut extensions = openmls_group.extensions().clone(); diff --git a/xmtp_mls/src/identity.rs b/xmtp_mls/src/identity.rs index 2c46ad2ad..605e7d204 100644 --- a/xmtp_mls/src/identity.rs +++ b/xmtp_mls/src/identity.rs @@ -5,11 +5,14 @@ use openmls::{ credentials::{ errors::{BasicCredentialError, CredentialError}, BasicCredential, - }, extensions::{errors::InvalidExtensionError, ApplicationIdExtension, LastResortExtension}, messages::proposals::ProposalType, prelude::{ + }, + extensions::{errors::InvalidExtensionError, ApplicationIdExtension, LastResortExtension}, + prelude::{ tls_codec::{Error as TlsCodecError, Serialize}, Capabilities, Credential as OpenMlsCredential, CredentialWithKey, CryptoConfig, Extension, ExtensionType, Extensions, KeyPackage, KeyPackageNewError, Lifetime, - }, versions::ProtocolVersion + }, + versions::ProtocolVersion, }; use openmls_basic_credential::SignatureKeyPair; use openmls_traits::{types::CryptoError, OpenMlsProvider}; @@ -195,7 +198,12 @@ impl Identity { let capabilities = Capabilities::new( None, Some(&[CIPHERSUITE]), - Some(&[ExtensionType::LastResort, ExtensionType::ApplicationId, ExtensionType::Unknown(0xff11), ExtensionType::ImmutableMetadata]), + Some(&[ + ExtensionType::LastResort, + ExtensionType::ApplicationId, + ExtensionType::Unknown(0xff11), + ExtensionType::ImmutableMetadata, + ]), None, None, );