Skip to content

Commit ef85db4

Browse files
committed
crypto: Remove Olm::import_room_keys altogether
1 parent 6bf6218 commit ef85db4

File tree

4 files changed

+8
-53
lines changed

4 files changed

+8
-53
lines changed

crates/matrix-sdk-crypto/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Breaking changes:
3131
- Add new `dehydrated` property to `olm::account::PickledAccount`.
3232
([#3164](https://github.com/matrix-org/matrix-rust-sdk/pull/3164))
3333

34+
- Remove deprecated `OlmMachine::import_room_keys`.
35+
([#3448](https://github.com/matrix-org/matrix-rust-sdk/pull/3448))
36+
3437
Deprecations:
3538

3639
- Deprecate `BackupMachine::import_backed_up_room_keys`.

crates/matrix-sdk-crypto/src/file_encryption/key_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub enum KeyExportError {
7474
/// # let machine = OlmMachine::new(&alice, device_id!("DEVICEID")).await;
7575
/// # let export = Cursor::new("".to_owned());
7676
/// let exported_keys = decrypt_room_key_export(export, "1234").unwrap();
77-
/// machine.import_room_keys(exported_keys, false, |_, _| {}).await.unwrap();
77+
/// machine.store().import_room_keys(exported_keys, None, |_, _| {}).await.unwrap();
7878
/// # };
7979
/// ```
8080
pub fn decrypt_room_key_export(

crates/matrix-sdk-crypto/src/machine.rs

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ use crate::{
6262
gossiping::GossipMachine,
6363
identities::{user::UserIdentities, Device, IdentityManager, UserDevices},
6464
olm::{
65-
Account, CrossSigningStatus, EncryptionSettings, ExportedRoomKey, IdentityKeys,
66-
InboundGroupSession, OlmDecryptionInfo, PrivateCrossSigningIdentity, SessionType,
67-
StaticAccountData,
65+
Account, CrossSigningStatus, EncryptionSettings, IdentityKeys, InboundGroupSession,
66+
OlmDecryptionInfo, PrivateCrossSigningIdentity, SessionType, StaticAccountData,
6867
},
6968
requests::{IncomingResponse, OutgoingRequest, UploadSigningKeysRequest},
7069
session_manager::{GroupSessionManager, SessionManager},
@@ -91,7 +90,7 @@ use crate::{
9190
utilities::timestamp_to_iso8601,
9291
verification::{Verification, VerificationMachine, VerificationRequest},
9392
CrossSigningKeyExport, CryptoStoreError, KeysQueryRequest, LocalTrust, ReadOnlyDevice,
94-
RoomKeyImportResult, SignatureError, ToDeviceRequest,
93+
SignatureError, ToDeviceRequest,
9594
};
9695

9796
/// State machine implementation of the Olm/Megolm encryption protocol used for
@@ -1783,53 +1782,6 @@ impl OlmMachine {
17831782
self.store().get_user_devices(user_id).await
17841783
}
17851784

1786-
/// Import the given room keys into our store.
1787-
///
1788-
/// # Arguments
1789-
///
1790-
/// * `exported_keys` - A list of previously exported keys that should be
1791-
/// imported into our store. If we already have a better version of a key
1792-
/// the key will *not* be imported.
1793-
///
1794-
/// * `from_backup` - Were the room keys imported from the backup, if true
1795-
/// will mark the room keys as already backed up. This will prevent backing
1796-
/// up keys that are already backed up.
1797-
///
1798-
/// Returns a tuple of numbers that represent the number of sessions that
1799-
/// were imported and the total number of sessions that were found in the
1800-
/// key export.
1801-
///
1802-
/// # Examples
1803-
///
1804-
/// ```no_run
1805-
/// # use std::io::Cursor;
1806-
/// # use matrix_sdk_crypto::{OlmMachine, decrypt_room_key_export};
1807-
/// # use ruma::{device_id, user_id};
1808-
/// # let alice = user_id!("@alice:example.org");
1809-
/// # async {
1810-
/// # let machine = OlmMachine::new(&alice, device_id!("DEVICEID")).await;
1811-
/// # let export = Cursor::new("".to_owned());
1812-
/// let exported_keys = decrypt_room_key_export(export, "1234").unwrap();
1813-
/// machine.import_room_keys(exported_keys, false, |_, _| {}).await.unwrap();
1814-
/// # };
1815-
/// ```
1816-
#[deprecated(
1817-
since = "0.7.0",
1818-
note = "Use the OlmMachine::store::import_room_keys method instead"
1819-
)]
1820-
pub async fn import_room_keys(
1821-
&self,
1822-
exported_keys: Vec<ExportedRoomKey>,
1823-
from_backup: bool,
1824-
progress_listener: impl Fn(usize, usize),
1825-
) -> StoreResult<RoomKeyImportResult> {
1826-
let backup_version =
1827-
if from_backup { self.backup_machine().backup_version().await } else { None };
1828-
self.store()
1829-
.import_room_keys(exported_keys, backup_version.as_deref(), progress_listener)
1830-
.await
1831-
}
1832-
18331785
/// Get the status of the private cross signing keys.
18341786
///
18351787
/// This can be used to check which private cross signing keys we have

crates/matrix-sdk-crypto/src/store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ impl Store {
17351735
/// # let machine = OlmMachine::new(&alice, device_id!("DEVICEID")).await;
17361736
/// # let export = Cursor::new("".to_owned());
17371737
/// let exported_keys = decrypt_room_key_export(export, "1234").unwrap();
1738-
/// machine.import_room_keys(exported_keys, false, |_, _| {}).await.unwrap();
1738+
/// machine.store().import_exported_room_keys(exported_keys, |_, _| {}).await.unwrap();
17391739
/// # };
17401740
/// ```
17411741
pub async fn import_exported_room_keys(

0 commit comments

Comments
 (0)