crypto: Add a pending requests method for the outbound group session

master
Damir Jelić 2021-01-18 12:44:19 +01:00
parent aadbc14dc6
commit 43a74524c5
2 changed files with 12 additions and 3 deletions

View File

@ -374,6 +374,15 @@ impl OutboundGroupSession {
.or_insert_with(DashSet::new)
.insert(device_id.to_owned());
}
/// Get the list of requests that need to be sent out for this session to be
/// marked as shared.
pub(crate) fn pending_requests(&self) -> Vec<Arc<ToDeviceRequest>> {
self.to_share_with_set
.iter()
.map(|i| i.value().clone())
.collect()
}
}
#[cfg(not(tarpaulin_include))]

View File

@ -244,7 +244,6 @@ impl GroupSessionManager {
.collect::<Vec<(&UserId, &DeviceId)>>()
);
let mut requests = Vec::new();
let key_content = outbound.as_json().await;
for device_map_chunk in devices.chunks(Self::MAX_TO_DEVICE_MESSAGES) {
@ -283,12 +282,13 @@ impl GroupSessionManager {
messages,
});
outbound.add_request(id, request.clone());
outbound.add_request(id, request);
self.outbound_sessions_being_shared
.insert(id, outbound.clone());
requests.push(request);
}
let requests = outbound.pending_requests();
if requests.is_empty() {
debug!(
"Session {} for room {} doesn't need to be shared with anyone, marking as shared",