diff --git a/xmtp_mls/src/builder.rs b/xmtp_mls/src/builder.rs index 8cf27a97b..70de1a37c 100644 --- a/xmtp_mls/src/builder.rs +++ b/xmtp_mls/src/builder.rs @@ -68,7 +68,7 @@ where } Ok(identity) } - None => Ok(Identity::new(store, provider, &owner)?), + None => Ok(Identity::new(provider, &owner)?), }, #[cfg(test)] IdentityStrategy::ExternalIdentity(identity) => Ok(identity), diff --git a/xmtp_mls/src/client.rs b/xmtp_mls/src/client.rs index 4d68bae22..14f974f4c 100644 --- a/xmtp_mls/src/client.rs +++ b/xmtp_mls/src/client.rs @@ -210,6 +210,8 @@ where let groups: Vec> = envelopes .into_iter() .filter_map(|envelope| { + // TODO: We can handle errors in the transaction() function to make error handling + // cleaner. Retryable errors can possibly be part of their own enum XmtpOpenMlsProvider::transaction(&mut conn, |provider| { let welcome = match extract_welcome(&envelope.message) { Ok(welcome) => welcome, @@ -221,12 +223,7 @@ where // TODO: Update last_message_timestamp_ns on success or non-retryable error // TODO: Abort if error is retryable - match MlsGroup::create_from_welcome( - self, - *provider.conn().borrow_mut(), - &provider, - welcome, - ) { + match MlsGroup::create_from_welcome(self, &provider, welcome) { Ok(mls_group) => Ok(Some(mls_group)), Err(err) => { log::error!("failed to create group from welcome: {}", err); diff --git a/xmtp_mls/src/groups/mod.rs b/xmtp_mls/src/groups/mod.rs index 52d0dc6cd..df468b06c 100644 --- a/xmtp_mls/src/groups/mod.rs +++ b/xmtp_mls/src/groups/mod.rs @@ -144,7 +144,6 @@ where pub fn create_from_welcome( client: &'c Client, - conn: &mut DbConnection, provider: &XmtpOpenMlsProvider, welcome: MlsWelcome, ) -> Result { @@ -155,7 +154,7 @@ where let group_id = mls_group.group_id().to_vec(); let stored_group = StoredGroup::new(group_id.clone(), now_ns(), GroupMembershipState::Pending); - stored_group.store(conn)?; + stored_group.store(*provider.conn().borrow_mut())?; Ok(Self::new(client, group_id, stored_group.created_at_ns)) } diff --git a/xmtp_mls/src/identity.rs b/xmtp_mls/src/identity.rs index 97ace2196..23e19110e 100644 --- a/xmtp_mls/src/identity.rs +++ b/xmtp_mls/src/identity.rs @@ -45,9 +45,8 @@ pub struct Identity { pub(crate) credential: Credential, } -impl<'a> Identity { +impl Identity { pub(crate) fn new( - store: &EncryptedMessageStore, provider: &XmtpOpenMlsProvider, owner: &impl InboxOwner, ) -> Result { @@ -63,8 +62,7 @@ impl<'a> Identity { }; identity.new_key_package(provider)?; - StoredIdentity::from(&identity).store(&mut store.conn()?)?; - // StoredIdentity::from(&identity).store(*provider.conn().borrow_mut())?; + StoredIdentity::from(&identity).store(*provider.conn().borrow_mut())?; // TODO: upload credential_with_key and last_resort_key_package @@ -154,7 +152,7 @@ mod tests { let store = EncryptedMessageStore::new_test(); let mut conn = store.conn().unwrap(); let provider = XmtpOpenMlsProvider::new(&mut conn); - Identity::new(&store, &provider, &generate_local_wallet()).unwrap(); + Identity::new(&provider, &generate_local_wallet()).unwrap(); } #[test] @@ -162,7 +160,7 @@ mod tests { let store = EncryptedMessageStore::new_test(); let mut conn = store.conn().unwrap(); let provider = XmtpOpenMlsProvider::new(&mut conn); - let identity = Identity::new(&store, &provider, &generate_local_wallet()).unwrap(); + let identity = Identity::new(&provider, &generate_local_wallet()).unwrap(); let new_key_package = identity.new_key_package(&provider).unwrap(); assert!(new_key_package