Skip to content

Commit

Permalink
feat(ui): Remove RoomListService::new_with_encryption.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hywan committed Nov 4, 2024
1 parent 5717eb1 commit 4002136
Showing 1 changed file with 3 additions and 41 deletions.
44 changes: 3 additions & 41 deletions crates/matrix-sdk-ui/src/room_list_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, Error> {
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, Error> {
Self::new_internal(client, true).await
}

async fn new_internal(client: Client, with_encryption: bool) -> Result<Self, Error> {
let mut builder = client
let builder = client
.sliding_sync("room-list")
.map_err(Error::SlidingSync)?
.with_account_data_extension(
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4002136

Please sign in to comment.