diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 76e349cf2..2146f4939 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -1710,9 +1710,8 @@ impl FfiConversation { } pub fn update_consent_state(&self, state: FfiConsentState) -> Result<(), GenericError> { - let provider = self.inner.mls_provider()?; self.inner - .update_consent_state(&provider, state.into()) + .update_consent_state(state.into()) .map_err(Into::into) } diff --git a/bindings_node/src/conversation.rs b/bindings_node/src/conversation.rs index 3c78849b5..98c27179b 100644 --- a/bindings_node/src/conversation.rs +++ b/bindings_node/src/conversation.rs @@ -642,10 +642,9 @@ impl Conversation { self.group_id.clone(), self.created_at_ns, ); - let provider = group.mls_provider().map_err(ErrorWrapper::from)?; group - .update_consent_state(&provider, state.into()) + .update_consent_state(state.into()) .map_err(ErrorWrapper::from)?; Ok(()) diff --git a/bindings_wasm/src/consent_state.rs b/bindings_wasm/src/consent_state.rs index 9a0e73595..938e53a11 100644 --- a/bindings_wasm/src/consent_state.rs +++ b/bindings_wasm/src/consent_state.rs @@ -127,11 +127,9 @@ impl Conversation { #[wasm_bindgen(js_name = updateConsentState)] pub fn update_consent_state(&self, state: ConsentState) -> Result<(), JsError> { let group = self.to_mls_group(); - let provider = group - .mls_provider() - .map_err(|e| JsError::new(&format!("{e}")))?; + group - .update_consent_state(&provider, state.into()) + .update_consent_state(state.into()) .map_err(|e| JsError::new(&format!("{e}")))?; Ok(()) diff --git a/xmtp_mls/src/groups/mod.rs b/xmtp_mls/src/groups/mod.rs index 3ba6648be..0d4049d9a 100644 --- a/xmtp_mls/src/groups/mod.rs +++ b/xmtp_mls/src/groups/mod.rs @@ -501,7 +501,7 @@ impl MlsGroup { let new_group = Self::new_from_arc(client.clone(), group_id, stored_group.created_at_ns); // Consent state defaults to allowed when the user creates the group - new_group.update_consent_state(&provider, ConsentState::Allowed)?; + new_group.update_consent_state(ConsentState::Allowed)?; Ok(new_group) } @@ -554,7 +554,7 @@ impl MlsGroup { stored_group.store(provider.conn_ref())?; let new_group = Self::new_from_arc(client.clone(), group_id, stored_group.created_at_ns); // Consent state defaults to allowed when the user creates the group - new_group.update_consent_state(&provider, ConsentState::Allowed)?; + new_group.update_consent_state(ConsentState::Allowed)?; Ok(new_group) } @@ -727,7 +727,7 @@ impl MlsGroup { self.sync_until_last_intent_resolved(provider).await?; // implicitly set group consent state to allowed - self.update_consent_state(provider, ConsentState::Allowed)?; + self.update_consent_state(ConsentState::Allowed)?; message_id } @@ -743,7 +743,7 @@ impl MlsGroup { self.sync_until_last_intent_resolved(&provider).await?; // implicitly set group consent state to allowed - self.update_consent_state(&provider, ConsentState::Allowed)?; + self.update_consent_state(ConsentState::Allowed)?; Ok(()) } @@ -1240,18 +1240,15 @@ impl MlsGroup { } } - pub fn update_consent_state( - &self, - provider: &XmtpOpenMlsProvider, - state: ConsentState, - ) -> Result<(), GroupError> { + pub fn update_consent_state(&self, state: ConsentState) -> Result<(), GroupError> { + let conn = self.context().store().conn()?; let consent_record = StoredConsentRecord::new( ConsentType::ConversationId, state, hex::encode(self.group_id.clone()), ); - provider.conn_ref().insert_or_replace_consent_records(&[consent_record.clone()])?; + conn.insert_or_replace_consent_records(&[consent_record.clone()])?; if self.client.history_sync_url().is_some() { // Dispatch an update event so it can be synced across devices @@ -3929,7 +3926,7 @@ pub(crate) mod tests { assert_eq!(alix_group.consent_state().unwrap(), ConsentState::Allowed); alix_group - .update_consent_state(&alix.mls_provider().unwrap(), ConsentState::Denied) + .update_consent_state(ConsentState::Denied) .unwrap(); assert_eq!(alix_group.consent_state().unwrap(), ConsentState::Denied);