From 2b8d4a21a4497dfa3cea75ce17498b9a3cb48861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 29 Sep 2020 17:40:06 +0200 Subject: [PATCH] crypto: Connect the key request handling to the main state machine. --- matrix_sdk_crypto/src/machine.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index ebe67f70..e3a2e48b 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -790,10 +790,6 @@ impl OlmMachine { } } - fn handle_room_key_request(&self, _: &ToDeviceEvent) { - // TODO handle room key requests here. - } - async fn handle_verification_event(&self, mut event: &mut AnyToDeviceEvent) { if let Err(e) = self.verification_machine.receive_event(&mut event).await { error!("Error handling a verification event: {:?}", e); @@ -884,7 +880,9 @@ impl OlmMachine { *event_result = decrypted_event; } - AnyToDeviceEvent::RoomKeyRequest(e) => self.handle_room_key_request(e), + AnyToDeviceEvent::RoomKeyRequest(e) => { + self.key_request_machine.receive_incoming_key_request(e) + } AnyToDeviceEvent::KeyVerificationAccept(..) | AnyToDeviceEvent::KeyVerificationCancel(..) | AnyToDeviceEvent::KeyVerificationKey(..) @@ -896,6 +894,12 @@ impl OlmMachine { _ => continue, } } + + // TODO remove this unwrap. + self.key_request_machine + .collect_incoming_key_requests() + .await + .unwrap(); } /// Decrypt an event from a room timeline.