From 4bfe48a499012b95d10c8c40148689b3200ede43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 19 Mar 2024 15:18:27 +0100 Subject: [PATCH] crypto: Remove the KeysBackup variant of the OutgoingRequest enum Backing up room keys isn't part of the outgoing requests processing loop, instead the user is supposed to have a separate loop calling `BackupMachine::backup()`. --- bindings/matrix-sdk-crypto-ffi/src/responses.rs | 1 - crates/matrix-sdk-crypto/src/backups/mod.rs | 9 +-------- crates/matrix-sdk-crypto/src/requests.rs | 8 -------- .../src/verification/event_enums.rs | 1 - crates/matrix-sdk/src/encryption/mod.rs | 17 ----------------- 5 files changed, 1 insertion(+), 35 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/src/responses.rs b/bindings/matrix-sdk-crypto-ffi/src/responses.rs index 17d115b3aa7..7f3a4501648 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/responses.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/responses.rs @@ -164,7 +164,6 @@ impl From for Request { }, RoomMessage(r) => Request::from(r), KeysClaim(c) => (r.request_id().to_owned(), c.clone()).into(), - KeysBackup(b) => (r.request_id().to_owned(), b.clone()).into(), } } } diff --git a/crates/matrix-sdk-crypto/src/backups/mod.rs b/crates/matrix-sdk-crypto/src/backups/mod.rs index 6d73cbc3561..e89f867bf6a 100644 --- a/crates/matrix-sdk-crypto/src/backups/mod.rs +++ b/crates/matrix-sdk-crypto/src/backups/mod.rs @@ -39,8 +39,7 @@ use crate::{ olm::{BackedUpRoomKey, ExportedRoomKey, InboundGroupSession, SignedJsonObject}, store::{BackupDecryptionKey, BackupKeys, Changes, RoomKeyCounts, Store}, types::{MegolmV1AuthData, RoomKeyBackupInfo, Signatures}, - CryptoStoreError, Device, KeysBackupRequest, OutgoingRequest, RoomKeyImportResult, - SignatureError, + CryptoStoreError, Device, KeysBackupRequest, RoomKeyImportResult, SignatureError, }; mod keys; @@ -70,12 +69,6 @@ struct PendingBackup { sessions: BTreeMap>>, } -impl From for OutgoingRequest { - fn from(b: PendingBackup) -> Self { - OutgoingRequest { request_id: b.request_id, request: Arc::new(b.request.into()) } - } -} - /// The result of a signature verification of a signed JSON object. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct SignatureVerification { diff --git a/crates/matrix-sdk-crypto/src/requests.rs b/crates/matrix-sdk-crypto/src/requests.rs index a716f1b0127..2a5751b7673 100644 --- a/crates/matrix-sdk-crypto/src/requests.rs +++ b/crates/matrix-sdk-crypto/src/requests.rs @@ -218,8 +218,6 @@ pub enum OutgoingRequests { /// A room message request, usually for sending in-room interactive /// verification events. RoomMessage(RoomMessageRequest), - /// A request that will back up a batch of room keys to the server. - KeysBackup(KeysBackupRequest), } #[cfg(test)] @@ -235,12 +233,6 @@ impl From for OutgoingRequests { } } -impl From for OutgoingRequests { - fn from(r: KeysBackupRequest) -> Self { - Self::KeysBackup(r) - } -} - impl From for OutgoingRequests { fn from(r: KeysClaimRequest) -> Self { Self::KeysClaim(r) diff --git a/crates/matrix-sdk-crypto/src/verification/event_enums.rs b/crates/matrix-sdk-crypto/src/verification/event_enums.rs index 45b45685f76..146d5a9a6ba 100644 --- a/crates/matrix-sdk-crypto/src/verification/event_enums.rs +++ b/crates/matrix-sdk-crypto/src/verification/event_enums.rs @@ -771,7 +771,6 @@ impl TryFrom for OutgoingContent { match value.request() { crate::OutgoingRequests::KeysUpload(_) | crate::OutgoingRequests::KeysQuery(_) - | crate::OutgoingRequests::KeysBackup(_) | crate::OutgoingRequests::SignatureUpload(_) | crate::OutgoingRequests::KeysClaim(_) => Err("Invalid request type".to_owned()), crate::OutgoingRequests::ToDeviceRequest(r) => Self::try_from(r.clone()), diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index de5774c1ac9..47b63cfb852 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -36,7 +36,6 @@ use matrix_sdk_base::crypto::{ use matrix_sdk_common::executor::spawn; use ruma::{ api::client::{ - backup::add_backup_keys::v3::Response as KeysBackupResponse, keys::{ get_keys, upload_keys, upload_signing_keys::v3::Request as UploadSigningKeysRequest, }, @@ -541,27 +540,11 @@ impl Client { let response = self.send(request.clone(), None).await?; self.mark_request_as_sent(r.request_id(), &response).await?; } - OutgoingRequests::KeysBackup(request) => { - let response = self.send_backup_request(request).await?; - self.mark_request_as_sent(r.request_id(), &response).await?; - } } Ok(()) } - async fn send_backup_request( - &self, - request: &matrix_sdk_base::crypto::KeysBackupRequest, - ) -> Result { - let request = ruma::api::client::backup::add_backup_keys::v3::Request::new( - request.version.clone(), - request.rooms.clone(), - ); - - Ok(self.send(request, None).await?) - } - pub(crate) async fn send_outgoing_requests(&self) -> Result<()> { const MAX_CONCURRENT_REQUESTS: usize = 20;