diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 6870a388c..e0f326bfa 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -329,6 +329,24 @@ impl FfiXmtpClient { Ok(state.into()) } + /** + * Get the inbox state for each `inbox_id`. + * + * If `refresh_from_network` is true, the client will go to the network first to refresh the state. + * Otherwise, the state will be read from the local database. + */ + pub async fn addresses_from_inbox_id( + &self, + refresh_from_network: bool, + inbox_ids: Vec, + ) -> Result, GenericError> { + let state = self + .inner_client + .inbox_addresses(refresh_from_network, inbox_ids) + .await?; + Ok(state.into_iter().map(Into::into).collect()) + } + pub async fn get_latest_inbox_state( &self, inbox_id: String, diff --git a/bindings_node/src/mls_client.rs b/bindings_node/src/mls_client.rs index d506160d0..e0075b47b 100644 --- a/bindings_node/src/mls_client.rs +++ b/bindings_node/src/mls_client.rs @@ -264,6 +264,20 @@ impl NapiClient { Ok(state.into()) } + #[napi] + pub async fn addresses_from_inbox_id( + &self, + refresh_from_network: bool, + inbox_ids: Vec, + ) -> Result> { + let state = self + .inner_client + .inbox_addresses(refresh_from_network, inbox_ids) + .await + .map_err(ErrorWrapper::from)?; + Ok(state.into_iter().map(Into::into).collect()) + } + #[napi] pub async fn get_latest_inbox_state(&self, inbox_id: String) -> Result { let conn = self diff --git a/xmtp_mls/src/client.rs b/xmtp_mls/src/client.rs index 969d45ef2..bd9b79452 100644 --- a/xmtp_mls/src/client.rs +++ b/xmtp_mls/src/client.rs @@ -373,6 +373,30 @@ where Ok(state) } + /// Get the [`AssociationState`] for each `inbox_id` + pub async fn inbox_addresses>( + &self, + refresh_from_network: bool, + inbox_ids: Vec, + ) -> Result, ClientError> { + let conn = self.store().conn()?; + if refresh_from_network { + load_identity_updates( + &self.api_client, + &conn, + inbox_ids.iter().map(|s| String::from(s.as_ref())).collect(), + ) + .await?; + } + let state = self + .batch_get_association_state( + &conn, + &inbox_ids.into_iter().map(|i| (i, None)).collect::>(), + ) + .await?; + Ok(state) + } + /// Set a consent record in the local database. /// If the consent record is an address set the consent state for both the address and `inbox_id` pub async fn set_consent_states(