crypto: Add a method to get all verification requests of a certain user

master
Damir Jelić 2021-06-17 10:03:47 +02:00
parent d212e7df18
commit 34703bc0d6
2 changed files with 12 additions and 0 deletions

View File

@ -731,6 +731,11 @@ impl OlmMachine {
self.verification_machine.get_request(user_id, flow_id)
}
/// Get all the verification requests of a given user.
pub fn get_verification_requests(&self, user_id: &UserId) -> Vec<VerificationRequest> {
self.verification_machine.get_requests(user_id)
}
async fn update_one_time_key_count(&self, key_count: &BTreeMap<DeviceKeyAlgorithm, UInt>) {
self.account.update_uploaded_key_count(key_count).await;
}

View File

@ -99,6 +99,13 @@ impl VerificationMachine {
self.requests.get(user_id).and_then(|v| v.get(flow_id.as_ref()).map(|s| s.clone()))
}
pub fn get_requests(&self, user_id: &UserId) -> Vec<VerificationRequest> {
self.requests
.get(user_id)
.map(|v| v.iter().map(|i| i.value().clone()).collect())
.unwrap_or_default()
}
fn insert_request(&self, request: VerificationRequest) {
self.requests
.entry(request.other_user().to_owned())