crypto: Add an user for a key request if the device was marked as wedged.

master
Damir Jelić 2020-10-15 15:02:02 +02:00
parent 59a7199202
commit 59d7b53242
1 changed files with 6 additions and 2 deletions

View File

@ -34,7 +34,7 @@ use crate::{
olm::Account, olm::Account,
requests::{OutgoingRequest, ToDeviceRequest}, requests::{OutgoingRequest, ToDeviceRequest},
store::{Result as StoreResult, Store}, store::{Result as StoreResult, Store},
Device, ReadOnlyDevice,
}; };
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -92,6 +92,10 @@ impl SessionManager {
if let Some(session) = session { if let Some(session) = session {
if session.creation_time.elapsed() > Self::UNWEDGING_INTERVAL { if session.creation_time.elapsed() > Self::UNWEDGING_INTERVAL {
self.users_for_key_claim
.entry(device.user_id().clone())
.or_insert_with(DashSet::new)
.insert(device.device_id().into());
self.wedged_devices self.wedged_devices
.entry(device.user_id().to_owned()) .entry(device.user_id().to_owned())
.or_insert_with(DashSet::new) .or_insert_with(DashSet::new)
@ -105,7 +109,7 @@ impl SessionManager {
} }
#[allow(dead_code)] #[allow(dead_code)]
pub fn is_device_wedged(&self, device: &Device) -> bool { pub fn is_device_wedged(&self, device: &ReadOnlyDevice) -> bool {
self.wedged_devices self.wedged_devices
.get(device.user_id()) .get(device.user_id())
.map(|d| d.contains(device.device_id())) .map(|d| d.contains(device.device_id()))