Skip to content

Commit

Permalink
revert 404e996
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Jan 9, 2025
1 parent 404e996 commit 02bbd89
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
3 changes: 1 addition & 2 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
3 changes: 1 addition & 2 deletions bindings_node/src/conversation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
6 changes: 2 additions & 4 deletions bindings_wasm/src/consent_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
19 changes: 8 additions & 11 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
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)
}

Expand Down Expand Up @@ -554,7 +554,7 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
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)
}

Expand Down Expand Up @@ -727,7 +727,7 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
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
}
Expand All @@ -743,7 +743,7 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
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(())
}
Expand Down Expand Up @@ -1240,18 +1240,15 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
}
}

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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 02bbd89

Please sign in to comment.