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

feat(ui): Remove RoomListService::new_with_encryption #4208

Merged
Merged
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
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
Loading