From 87ac94c67588a48c240a9f3da81f07a91866db61 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 4 Nov 2024 15:00:16 +0100 Subject: [PATCH] feat(ui): Remove `RoomListService::new_with_encryption`. This patch removes `RoomListService::new_with_encryption`. This feature is not used, not useful since it's best to use `EncryptionSyncService`, and it can be racy depending on how it's used. To avoid potential errors and bugs, it's preferable to remove this code. --- .../src/room_list_service/mod.rs | 44 ++----------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/crates/matrix-sdk-ui/src/room_list_service/mod.rs b/crates/matrix-sdk-ui/src/room_list_service/mod.rs index 0fd2ba165f3..85c8655a50e 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/mod.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/mod.rs @@ -120,21 +120,10 @@ impl RoomListService { /// already pre-configured. /// /// This won't start an encryption sync, and it's the user's responsibility - /// to create one in this case using `EncryptionSync`. + /// to create one in this case using + /// [`EncryptionSyncService`][crate::encryption_sync_service::EncryptionSyncService]. pub async fn new(client: Client) -> Result { - Self::new_internal(client, false).await - } - - /// Create a new `RoomList` that enables encryption. - /// - /// This will include syncing the encryption information, so there must not - /// be any instance of `EncryptionSync` running in the background. - pub async fn new_with_encryption(client: Client) -> Result { - Self::new_internal(client, true).await - } - - async fn new_internal(client: Client, with_encryption: bool) -> Result { - let mut builder = client + let builder = client .sliding_sync("room-list") .map_err(Error::SlidingSync)? .with_account_data_extension( @@ -148,16 +137,6 @@ impl RoomListService { enabled: Some(true), })); - if with_encryption { - builder = builder - .with_e2ee_extension( - assign!(http::request::E2EE::default(), { enabled: Some(true) }), - ) - .with_to_device_extension( - assign!(http::request::ToDevice::default(), { enabled: Some(true) }), - ); - } - let sliding_sync = builder .add_cached_list( SlidingSyncList::builder(ALL_ROOMS_LIST_NAME) @@ -577,23 +556,6 @@ mod tests { Ok(()) } - #[async_test] - async fn test_no_to_device_and_e2ee_if_not_explicitly_set() -> Result<(), Error> { - let (client, _) = new_client().await; - - let no_encryption = RoomListService::new(client.clone()).await?; - let extensions = no_encryption.sliding_sync.extensions_config(); - assert_eq!(extensions.e2ee.enabled, None); - assert_eq!(extensions.to_device.enabled, None); - - let with_encryption = RoomListService::new_with_encryption(client).await?; - let extensions = with_encryption.sliding_sync.extensions_config(); - assert_eq!(extensions.e2ee.enabled, Some(true)); - assert_eq!(extensions.to_device.enabled, Some(true)); - - Ok(()) - } - #[async_test] async fn test_expire_sliding_sync_session_manually() -> Result<(), Error> { let (client, server) = new_client().await;