diff --git a/crates/matrix-sdk-crypto-nodejs/src/machine.rs b/crates/matrix-sdk-crypto-nodejs/src/machine.rs index 1ec39373c..c4c47528d 100644 --- a/crates/matrix-sdk-crypto-nodejs/src/machine.rs +++ b/crates/matrix-sdk-crypto-nodejs/src/machine.rs @@ -152,10 +152,36 @@ impl OlmMachine { .map_err(into_err) } + #[napi] + pub async fn get_missing_sessions( + &self, + users: Vec<&identifiers::UserId>, + ) -> Result, napi::Error> { + let users = + users.into_iter().map(|user| user.inner.clone()).collect::>(); + + match self + .inner + .get_missing_sessions(users.iter().map(AsRef::as_ref)) + .await + .map_err(into_err)? + { + Some((transaction_id, keys_claim_request)) => Ok(Some( + requests::KeysClaimRequest::try_from(( + transaction_id.to_string(), + &keys_claim_request, + )) + .map_err(into_err)?, + )), + + None => Ok(None), + } + } + #[napi] pub async fn update_tracked_users(&self, users: Vec<&identifiers::UserId>) { - let users: Vec = - users.into_iter().map(|user| user.inner.clone()).collect(); + let users = + users.into_iter().map(|user| user.inner.clone()).collect::>(); self.inner.update_tracked_users(users.iter().map(AsRef::as_ref)).await; }