Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: Remove the KeysBackup variant of the OutgoingRequest enum #3245

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bindings/matrix-sdk-crypto-ffi/src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ impl From<OutgoingRequest> 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(),
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions crates/matrix-sdk-crypto/src/backups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,12 +69,6 @@ struct PendingBackup {
sessions: BTreeMap<OwnedRoomId, BTreeMap<SenderKey, BTreeSet<SessionId>>>,
}

impl From<PendingBackup> 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 {
Expand Down
8 changes: 0 additions & 8 deletions crates/matrix-sdk-crypto/src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -235,12 +233,6 @@ impl From<KeysQueryRequest> for OutgoingRequests {
}
}

impl From<KeysBackupRequest> for OutgoingRequests {
fn from(r: KeysBackupRequest) -> Self {
Self::KeysBackup(r)
}
}

impl From<KeysClaimRequest> for OutgoingRequests {
fn from(r: KeysClaimRequest) -> Self {
Self::KeysClaim(r)
Expand Down
1 change: 0 additions & 1 deletion crates/matrix-sdk-crypto/src/verification/event_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,6 @@ impl TryFrom<OutgoingRequest> 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()),
Expand Down
17 changes: 0 additions & 17 deletions crates/matrix-sdk/src/encryption/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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<KeysBackupResponse> {
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;

Expand Down
Loading