Skip to content

Commit

Permalink
Revert push to main 404e996 (#1481)
Browse files Browse the repository at this point in the history
* revert 404e996

* lint fix rust 1.8.4 (#1482)

Co-authored-by: cameronvoell <[email protected]>

---------

Co-authored-by: cameronvoell <[email protected]>
  • Loading branch information
cameronvoell and cameronvoell authored Jan 9, 2025
1 parent 404e996 commit 6d39b35
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 38 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
4 changes: 2 additions & 2 deletions xmtp_mls/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ where
}

/// Get the [`AssociationState`] for each `inbox_id`
pub async fn inbox_addresses<'a>(
pub async fn inbox_addresses(
&self,
refresh_from_network: bool,
inbox_ids: Vec<InboxIdRef<'a>>,
inbox_ids: Vec<InboxIdRef<'_>>,
) -> Result<Vec<AssociationState>, ClientError> {
let conn = self.store().conn()?;
if refresh_from_network {
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
32 changes: 16 additions & 16 deletions xmtp_mls/src/groups/scoped_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ pub trait LocalScopedGroupClient: Send + Sync + Sized {
installation_ids: Vec<Vec<u8>>,
) -> Result<Vec<VerifiedKeyPackageV2>, ClientError>;

async fn get_association_state<'a>(
async fn get_association_state(
&self,
conn: &DbConnection,
inbox_id: InboxIdRef<'a>,
inbox_id: InboxIdRef<'_>,
to_sequence_id: Option<i64>,
) -> Result<AssociationState, ClientError>;

async fn batch_get_association_state<'a>(
async fn batch_get_association_state(
&self,
conn: &DbConnection,
identifiers: &[(InboxIdRef<'a>, Option<i64>)],
identifiers: &[(InboxIdRef<'_>, Option<i64>)],
) -> Result<Vec<AssociationState>, ClientError>;

async fn query_group_messages(
Expand Down Expand Up @@ -201,10 +201,10 @@ where
.await
}

async fn get_association_state<'a>(
async fn get_association_state(
&self,
conn: &DbConnection,
inbox_id: InboxIdRef<'a>,
inbox_id: InboxIdRef<'_>,
to_sequence_id: Option<i64>,
) -> Result<AssociationState, ClientError> {
crate::Client::<ApiClient, Verifier>::get_association_state(
Expand All @@ -216,10 +216,10 @@ where
.await
}

async fn batch_get_association_state<'a>(
async fn batch_get_association_state(
&self,
conn: &DbConnection,
identifiers: &[(InboxIdRef<'a>, Option<i64>)],
identifiers: &[(InboxIdRef<'_>, Option<i64>)],
) -> Result<Vec<AssociationState>, ClientError> {
crate::Client::<ApiClient, Verifier>::batch_get_association_state(self, conn, identifiers)
.await
Expand Down Expand Up @@ -294,21 +294,21 @@ where
.await
}

async fn get_association_state<'a>(
async fn get_association_state(
&self,
conn: &DbConnection,
inbox_id: InboxIdRef<'a>,
inbox_id: InboxIdRef<'_>,
to_sequence_id: Option<i64>,
) -> Result<AssociationState, ClientError> {
(**self)
.get_association_state(conn, inbox_id, to_sequence_id)
.await
}

async fn batch_get_association_state<'a>(
async fn batch_get_association_state(
&self,
conn: &DbConnection,
identifiers: &[(InboxIdRef<'a>, Option<i64>)],
identifiers: &[(InboxIdRef<'_>, Option<i64>)],
) -> Result<Vec<AssociationState>, ClientError> {
(**self)
.batch_get_association_state(conn, identifiers)
Expand Down Expand Up @@ -384,21 +384,21 @@ where
.await
}

async fn get_association_state<'a>(
async fn get_association_state(
&self,
conn: &DbConnection,
inbox_id: InboxIdRef<'a>,
inbox_id: InboxIdRef<'_>,
to_sequence_id: Option<i64>,
) -> Result<AssociationState, ClientError> {
(**self)
.get_association_state(conn, inbox_id, to_sequence_id)
.await
}

async fn batch_get_association_state<'a>(
async fn batch_get_association_state(
&self,
conn: &DbConnection,
identifiers: &[(InboxIdRef<'a>, Option<i64>)],
identifiers: &[(InboxIdRef<'_>, Option<i64>)],
) -> Result<Vec<AssociationState>, ClientError> {
(**self)
.batch_get_association_state(conn, identifiers)
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/validated_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ struct ExpectedDiff {
/// [`GroupMembership`] and the [`GroupMembership`] found in the [`StagedCommit`].
/// This requires loading the Inbox state from the network.
/// Satisfies Rule 2
async fn extract_expected_diff<'diff>(
async fn extract_expected_diff(
conn: &DbConnection,
client: impl ScopedGroupClient,
staged_commit: &StagedCommit,
Expand Down

0 comments on commit 6d39b35

Please sign in to comment.