crypto: Return a result when searching for missing sessions.
parent
6d67cd2ac7
commit
96144404ed
|
@ -898,7 +898,7 @@ impl AsyncClient {
|
|||
.read()
|
||||
.await
|
||||
.get_missing_sessions(users)
|
||||
.await
|
||||
.await?
|
||||
};
|
||||
|
||||
if !missing_sessions.is_empty() {
|
||||
|
|
|
@ -435,12 +435,12 @@ impl Client {
|
|||
pub async fn get_missing_sessions(
|
||||
&self,
|
||||
users: impl Iterator<Item = &UserId>,
|
||||
) -> BTreeMap<UserId, BTreeMap<DeviceId, KeyAlgorithm>> {
|
||||
) -> Result<BTreeMap<UserId, BTreeMap<DeviceId, KeyAlgorithm>>> {
|
||||
let mut olm = self.olm.lock().await;
|
||||
|
||||
match &mut *olm {
|
||||
Some(o) => o.get_missing_sessions(users).await,
|
||||
None => BTreeMap::new(),
|
||||
Some(o) => Ok(o.get_missing_sessions(users).await?),
|
||||
None => Ok(BTreeMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,11 +202,11 @@ impl OlmMachine {
|
|||
pub async fn get_missing_sessions(
|
||||
&mut self,
|
||||
users: impl Iterator<Item = &UserId>,
|
||||
) -> BTreeMap<UserId, BTreeMap<DeviceId, KeyAlgorithm>> {
|
||||
) -> Result<BTreeMap<UserId, BTreeMap<DeviceId, KeyAlgorithm>>> {
|
||||
let mut missing = BTreeMap::new();
|
||||
|
||||
for user_id in users {
|
||||
let user_devices = self.store.get_user_devices(user_id).await.unwrap();
|
||||
let user_devices = self.store.get_user_devices(user_id).await?;
|
||||
|
||||
for device in user_devices.devices() {
|
||||
let sender_key = if let Some(k) = device.get_key(&KeyAlgorithm::Curve25519) {
|
||||
|
@ -215,7 +215,7 @@ impl OlmMachine {
|
|||
continue;
|
||||
};
|
||||
|
||||
let sessions = self.store.get_sessions(sender_key).await.unwrap();
|
||||
let sessions = self.store.get_sessions(sender_key).await?;
|
||||
|
||||
let is_missing = if let Some(sessions) = sessions {
|
||||
sessions.lock().await.is_empty()
|
||||
|
@ -237,7 +237,7 @@ impl OlmMachine {
|
|||
}
|
||||
}
|
||||
|
||||
missing
|
||||
Ok(missing)
|
||||
}
|
||||
|
||||
pub async fn receive_keys_claim_response(
|
||||
|
|
Loading…
Reference in New Issue