Skip to content

Commit 1eecb2d

Browse files
committed
ui: Remove the e2e-encryption feature from the matrix-sdk-ui crate
It does not make much sense to create an UI client that does not support end-to-end encryption, besides disabling the feature was broken for quite some time.
1 parent 98ba714 commit 1eecb2d

File tree

12 files changed

+32
-68
lines changed

12 files changed

+32
-68
lines changed

bindings/matrix-sdk-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ eyeball-im = { workspace = true }
2828
extension-trait = "1.0.1"
2929
futures-util = { workspace = true }
3030
log-panics = { version = "2", features = ["with-backtrace"] }
31-
matrix-sdk-ui = { workspace = true, features = ["e2e-encryption", "uniffi"] }
31+
matrix-sdk-ui = { workspace = true, features = ["uniffi"] }
3232
mime = "0.3.16"
3333
once_cell = { workspace = true }
3434
ruma = { workspace = true, features = ["html", "unstable-unspecified", "unstable-msc3488", "compat-unset-avatar", "unstable-msc3245-v1-compat"] }

crates/matrix-sdk-ui/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ license = "Apache-2.0"
88
rust-version = { workspace = true }
99

1010
[features]
11-
default = ["e2e-encryption", "native-tls"]
12-
13-
e2e-encryption = ["matrix-sdk/e2e-encryption"]
11+
default = ["native-tls"]
1412

1513
native-tls = ["matrix-sdk/native-tls"]
1614
rustls-tls = ["matrix-sdk/rustls-tls"]
@@ -37,7 +35,7 @@ growable-bloom-filter = { workspace = true }
3735
imbl = { workspace = true, features = ["serde"] }
3836
indexmap = "2.0.0"
3937
itertools = { workspace = true }
40-
matrix-sdk = { workspace = true, features = ["experimental-sliding-sync"] }
38+
matrix-sdk = { workspace = true, features = ["experimental-sliding-sync", "e2e-encryption"] }
4139
matrix-sdk-base = { workspace = true }
4240
mime = "0.3.16"
4341
once_cell = { workspace = true }

crates/matrix-sdk-ui/src/timeline/builder.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ use ruma::{events::AnySyncTimelineEvent, RoomVersionId};
2424
use tokio::sync::broadcast::error::RecvError;
2525
use tracing::{info, info_span, trace, warn, Instrument, Span};
2626

27-
#[cfg(feature = "e2e-encryption")]
28-
use super::to_device::{handle_forwarded_room_key_event, handle_room_key_event};
2927
use super::{
3028
controller::{TimelineController, TimelineSettings},
29+
to_device::{handle_forwarded_room_key_event, handle_room_key_event},
3130
Error, Timeline, TimelineDropHandle, TimelineFocus,
3231
};
3332
use crate::{
@@ -330,23 +329,17 @@ impl TimelineBuilder {
330329
// Not using room.add_event_handler here because RoomKey events are
331330
// to-device events that are not received in the context of a room.
332331

333-
#[cfg(feature = "e2e-encryption")]
334332
let room_key_handle = client.add_event_handler(handle_room_key_event(
335333
controller.clone(),
336334
room.room_id().to_owned(),
337335
));
338-
#[cfg(feature = "e2e-encryption")]
336+
339337
let forwarded_room_key_handle = client.add_event_handler(handle_forwarded_room_key_event(
340338
controller.clone(),
341339
room.room_id().to_owned(),
342340
));
343341

344-
let handles = vec![
345-
#[cfg(feature = "e2e-encryption")]
346-
room_key_handle,
347-
#[cfg(feature = "e2e-encryption")]
348-
forwarded_room_key_handle,
349-
];
342+
let handles = vec![room_key_handle, forwarded_room_key_handle];
350343

351344
let room_key_from_backups_join_handle = {
352345
let inner = controller.clone();
@@ -391,7 +384,6 @@ impl TimelineBuilder {
391384
}),
392385
};
393386

394-
#[cfg(feature = "e2e-encryption")]
395387
if has_events {
396388
// The events we're injecting might be encrypted events, but we might
397389
// have received the room key to decrypt them while nobody was listening to the

crates/matrix-sdk-ui/src/timeline/controller/mod.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(feature = "e2e-encryption")]
16-
use std::collections::BTreeSet;
17-
use std::{fmt, sync::Arc};
15+
use std::{collections::BTreeSet, fmt, sync::Arc};
1816

1917
use as_variant::as_variant;
2018
use eyeball_im::{ObservableVectorEntry, VectorDiff};
2119
use eyeball_im_util::vector::VectorObserverExt;
2220
use futures_core::Stream;
2321
use imbl::Vector;
24-
#[cfg(all(test, feature = "e2e-encryption"))]
22+
#[cfg(test)]
2523
use matrix_sdk::crypto::OlmMachine;
2624
use matrix_sdk::{
2725
deserialized_responses::SyncTimelineEvent,
@@ -31,10 +29,6 @@ use matrix_sdk::{
3129
},
3230
Result, Room,
3331
};
34-
#[cfg(test)]
35-
use ruma::events::receipt::ReceiptEventContent;
36-
#[cfg(all(test, feature = "e2e-encryption"))]
37-
use ruma::RoomId;
3832
use ruma::{
3933
api::client::receipt::create_receipt::v3::ReceiptType as SendReceiptType,
4034
events::{
@@ -50,21 +44,21 @@ use ruma::{
5044
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedTransactionId, RoomVersionId,
5145
TransactionId, UserId,
5246
};
47+
#[cfg(test)]
48+
use ruma::{events::receipt::ReceiptEventContent, RoomId};
5349
use tokio::sync::{RwLock, RwLockWriteGuard};
54-
use tracing::{debug, error, field::debug, info, instrument, trace, warn};
55-
#[cfg(feature = "e2e-encryption")]
56-
use tracing::{field, info_span, Instrument as _};
50+
use tracing::{
51+
debug, error, field, field::debug, info, info_span, instrument, trace, warn, Instrument as _,
52+
};
5753

5854
pub(super) use self::state::{
5955
EventMeta, FullEventMeta, TimelineEnd, TimelineMetadata, TimelineState,
6056
TimelineStateTransaction,
6157
};
62-
#[cfg(feature = "e2e-encryption")]
63-
use super::traits::Decryptor;
6458
use super::{
6559
event_handler::TimelineEventKind,
6660
event_item::{ReactionStatus, RemoteEventOrigin},
67-
traits::RoomDataProvider,
61+
traits::{Decryptor, RoomDataProvider},
6862
util::{rfind_event_by_id, rfind_event_item, RelativePosition},
6963
Error, EventSendState, EventTimelineItem, InReplyToDetails, Message, PaginationError, Profile,
7064
ReactionInfo, RepliedToEvent, TimelineDetails, TimelineEventItemId, TimelineFocus,
@@ -939,7 +933,6 @@ impl<P: RoomDataProvider> TimelineController<P> {
939933
true
940934
}
941935

942-
#[cfg(feature = "e2e-encryption")]
943936
#[instrument(skip(self, room), fields(room_id = ?room.room_id()))]
944937
pub(super) async fn retry_event_decryption(
945938
&self,
@@ -949,7 +942,7 @@ impl<P: RoomDataProvider> TimelineController<P> {
949942
self.retry_event_decryption_inner(room.to_owned(), session_ids).await
950943
}
951944

952-
#[cfg(all(test, feature = "e2e-encryption"))]
945+
#[cfg(test)]
953946
pub(super) async fn retry_event_decryption_test(
954947
&self,
955948
room_id: &RoomId,
@@ -959,7 +952,6 @@ impl<P: RoomDataProvider> TimelineController<P> {
959952
self.retry_event_decryption_inner((olm_machine, room_id.to_owned()), session_ids).await
960953
}
961954

962-
#[cfg(feature = "e2e-encryption")]
963955
async fn retry_event_decryption_inner(
964956
&self,
965957
decryptor: impl Decryptor,

crates/matrix-sdk-ui/src/timeline/controller/state.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ impl TimelineState {
198198
txn.commit();
199199
}
200200

201-
#[cfg(feature = "e2e-encryption")]
202201
pub(super) async fn retry_event_decryption<P: RoomDataProvider, Fut>(
203202
&mut self,
204203
retry_one: impl Fn(Arc<TimelineItem>) -> Fut,
@@ -635,7 +634,6 @@ impl TimelineStateTransaction<'_> {
635634
self.meta.all_events.push_back(event_meta.base_meta());
636635
}
637636

638-
#[cfg(feature = "e2e-encryption")]
639637
TimelineItemPosition::Update(_) => {
640638
if let Some(event) =
641639
self.meta.all_events.iter_mut().find(|e| e.event_id == event_meta.event_id)

crates/matrix-sdk-ui/src/timeline/event_handler.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ pub(super) enum TimelineItemPosition {
234234
/// A single item is updated.
235235
///
236236
/// This only happens when a UTD must be replaced with the decrypted event.
237-
#[cfg(feature = "e2e-encryption")]
238237
Update(usize),
239238
}
240239

@@ -249,7 +248,6 @@ pub(super) struct HandleEventResult {
249248
///
250249
/// This can happen only if there was a UTD item that has been decrypted
251250
/// into an item that was filtered out with the event filter.
252-
#[cfg(feature = "e2e-encryption")]
253251
pub(super) item_removed: bool,
254252

255253
/// How many items were updated?
@@ -433,7 +431,6 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
433431
if !self.result.item_added {
434432
trace!("No new item added");
435433

436-
#[cfg(feature = "e2e-encryption")]
437434
if let Flow::Remote { position: TimelineItemPosition::Update(idx), .. } = self.ctx.flow
438435
{
439436
// If add was not called, that means the UTD event is one that
@@ -821,7 +818,6 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
821818
| TimelineItemPosition::End { origin } => origin,
822819

823820
// For updates, reuse the origin of the encrypted event.
824-
#[cfg(feature = "e2e-encryption")]
825821
TimelineItemPosition::Update(idx) => self.items[idx]
826822
.as_event()
827823
.and_then(|ev| Some(ev.as_remote()?.origin))
@@ -966,7 +962,6 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
966962
}
967963
}
968964

969-
#[cfg(feature = "e2e-encryption")]
970965
Flow::Remote { position: TimelineItemPosition::Update(idx), .. } => {
971966
trace!("Updating timeline item at position {idx}");
972967
let id = self.items[*idx].internal_id.clone();

crates/matrix-sdk-ui/src/timeline/event_item/remote.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ pub(in crate::timeline) enum RemoteEventOrigin {
8989
/// The event came from pagination.
9090
Pagination,
9191
/// We don't know.
92-
#[cfg(feature = "e2e-encryption")]
9392
Unknown,
9493
}
9594

crates/matrix-sdk-ui/src/timeline/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ mod reactions;
7676
mod read_receipts;
7777
#[cfg(test)]
7878
mod tests;
79-
#[cfg(feature = "e2e-encryption")]
8079
mod to_device;
8180
mod traits;
8281
mod util;
@@ -217,7 +216,6 @@ impl Timeline {
217216
/// }
218217
/// # anyhow::Ok(()) };
219218
/// ```
220-
#[cfg(feature = "e2e-encryption")]
221219
pub async fn retry_decryption<S: Into<String>>(
222220
&self,
223221
session_ids: impl IntoIterator<Item = S>,
@@ -230,7 +228,6 @@ impl Timeline {
230228
.await;
231229
}
232230

233-
#[cfg(feature = "e2e-encryption")]
234231
#[tracing::instrument(skip(self))]
235232
async fn retry_decryption_for_all_events(&self) {
236233
self.controller.retry_event_decryption(self.room(), None).await;

crates/matrix-sdk-ui/src/timeline/tests/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ use crate::{
6868
mod basic;
6969
mod echo;
7070
mod edit;
71-
#[cfg(feature = "e2e-encryption")]
7271
mod encryption;
7372
mod event_filter;
7473
mod invalid;

crates/matrix-sdk-ui/src/timeline/tests/read_receipts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ async fn test_read_receipts_updates_on_back_paginated_filtered_events() {
329329
assert_pending!(stream);
330330
}
331331

332-
#[cfg(feature = "e2e-encryption")]
333332
#[async_test]
334333
async fn test_read_receipts_updates_on_message_decryption() {
335334
use std::{io::Cursor, iter};

crates/matrix-sdk-ui/src/timeline/traits.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ use std::future::Future;
1616

1717
use futures_util::FutureExt as _;
1818
use indexmap::IndexMap;
19-
#[cfg(all(test, feature = "e2e-encryption"))]
19+
#[cfg(test)]
2020
use matrix_sdk::crypto::{DecryptionSettings, TrustRequirement};
21-
#[cfg(feature = "e2e-encryption")]
22-
use matrix_sdk::{deserialized_responses::TimelineEvent, Result};
23-
use matrix_sdk::{event_cache::paginator::PaginableRoom, BoxFuture, Room};
21+
use matrix_sdk::{
22+
deserialized_responses::TimelineEvent, event_cache::paginator::PaginableRoom, BoxFuture,
23+
Result, Room,
24+
};
2425
use matrix_sdk_base::latest_event::LatestEvent;
25-
#[cfg(feature = "e2e-encryption")]
26-
use ruma::{events::AnySyncTimelineEvent, serde::Raw};
2726
use ruma::{
2827
events::{
2928
fully_read::FullyReadEventContent,
3029
receipt::{Receipt, ReceiptThread, ReceiptType},
31-
AnyMessageLikeEventContent,
30+
AnyMessageLikeEventContent, AnySyncTimelineEvent,
3231
},
3332
push::{PushConditionRoomCtx, Ruleset},
33+
serde::Raw,
3434
EventId, OwnedEventId, OwnedTransactionId, OwnedUserId, RoomVersionId, UserId,
3535
};
3636
use tracing::{debug, error};
@@ -275,22 +275,20 @@ impl RoomDataProvider for Room {
275275

276276
// Internal helper to make most of retry_event_decryption independent of a room
277277
// object, which is annoying to create for testing and not really needed
278-
#[cfg(feature = "e2e-encryption")]
279278
pub(super) trait Decryptor: Clone + Send + Sync + 'static {
280279
fn decrypt_event_impl(
281280
&self,
282281
raw: &Raw<AnySyncTimelineEvent>,
283282
) -> impl Future<Output = Result<TimelineEvent>> + Send;
284283
}
285284

286-
#[cfg(feature = "e2e-encryption")]
287285
impl Decryptor for Room {
288286
async fn decrypt_event_impl(&self, raw: &Raw<AnySyncTimelineEvent>) -> Result<TimelineEvent> {
289287
self.decrypt_event(raw.cast_ref()).await
290288
}
291289
}
292290

293-
#[cfg(all(test, feature = "e2e-encryption"))]
291+
#[cfg(test)]
294292
impl Decryptor for (matrix_sdk_base::crypto::OlmMachine, ruma::OwnedRoomId) {
295293
async fn decrypt_event_impl(&self, raw: &Raw<AnySyncTimelineEvent>) -> Result<TimelineEvent> {
296294
let (olm_machine, room_id) = self;

crates/matrix-sdk-ui/tests/integration/encryption_sync_service.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::sync::{Arc, Mutex};
22

33
use futures_util::{pin_mut, StreamExt as _};
44
use matrix_sdk::test_utils::logged_in_client_with_server;
5+
use matrix_sdk_base::crypto::store::Changes;
56
use matrix_sdk_test::async_test;
67
use matrix_sdk_ui::encryption_sync_service::{
78
EncryptionSyncPermit, EncryptionSyncService, WithLocking,
@@ -291,18 +292,14 @@ async fn test_encryption_sync_always_reloads_todevice_token() -> anyhow::Result<
291292
// This encryption sync now conceptually goes to sleep, and another encryption
292293
// sync starts in another process, runs a sync and changes the to-device
293294
// token cached on disk.
294-
#[cfg(feature = "e2e-encryption")]
295-
{
296-
use matrix_sdk_base::crypto::store::Changes;
297-
if let Some(olm_machine) = &*client.olm_machine_for_testing().await {
298-
olm_machine
299-
.store()
300-
.save_changes(Changes {
301-
next_batch_token: Some("nb2".to_owned()),
302-
..Default::default()
303-
})
304-
.await?;
305-
}
295+
if let Some(olm_machine) = &*client.olm_machine_for_testing().await {
296+
olm_machine
297+
.store()
298+
.save_changes(Changes {
299+
next_batch_token: Some("nb2".to_owned()),
300+
..Default::default()
301+
})
302+
.await?;
306303
}
307304

308305
// Next iteration must have reloaded the latest to-device token.

0 commit comments

Comments
 (0)