Skip to content

Commit 435b449

Browse files
committed
feat: fixup
1 parent 1748fcd commit 435b449

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

crates/matrix-sdk/src/room/futures.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,12 @@ impl<'a> SendStateEventRaw<'a> {
407407
}
408408

409409
/// Returns `true` if the inner event should be encrypted.
410+
#[cfg(feature = "e2e-encryption")]
410411
fn should_encrypt(room: &Room, event_type: &str) -> bool {
412+
use tracing::debug;
413+
411414
if !room.encryption_state().is_state_encrypted() {
412-
trace!("Sending plaintext event as the room does NOT support encrypted state events.");
415+
debug!("Sending plaintext event as the room does NOT support encrypted state events.");
413416
return false;
414417
}
415418

@@ -427,6 +430,7 @@ impl<'a> SendStateEventRaw<'a> {
427430
| "m.space.child"
428431
| "m.space.parent"
429432
) {
433+
debug!("Sending plaintext event as its type is excluded from encryption.");
430434
return false;
431435
}
432436

@@ -448,8 +452,10 @@ impl<'a> IntoFuture for SendStateEventRaw<'a> {
448452

449453
#[cfg(feature = "e2e-encryption")]
450454
if Self::should_encrypt(room, event_type) {
455+
use tracing::debug;
456+
451457
Span::current().record("is_room_encrypted", true);
452-
trace!(
458+
debug!(
453459
room_id = ?room.room_id(),
454460
"Sending encrypted event because the room is encrypted.",
455461
);

testing/matrix-sdk-integration-testing/src/tests/e2ee/state_events.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ops::Deref;
1+
use std::{ops::Deref, time::Duration};
22

33
use anyhow::Result;
44
use assert_matches2::assert_let;
@@ -29,6 +29,7 @@ async fn test_e2ee_state_events() -> Result<()> {
2929

3030
let alice = TestClientBuilder::new("alice")
3131
.use_sqlite()
32+
.http_proxy("http://localhost:8080/".to_owned())
3233
.encryption_settings(encryption_settings)
3334
.enable_share_history_on_invite(true)
3435
.build()
@@ -52,7 +53,7 @@ async fn test_e2ee_state_events() -> Result<()> {
5253
.await?,
5354
);
5455

55-
// Alice creates a room ...
56+
// Alice creates an encrypted room ...
5657
let alice_room = alice
5758
.create_room(assign!(CreateRoomRequest::new(), {
5859
name: Some("Cat Photos".to_owned()),
@@ -61,6 +62,16 @@ async fn test_e2ee_state_events() -> Result<()> {
6162
.await?;
6263
alice_room.enable_encryption_with_state().await?;
6364

65+
// HACK: wait for sync
66+
let _ = tokio::time::sleep(Duration::from_secs(3)).await;
67+
68+
// (sanity checks)
69+
assert!(alice_room.encryption_state().is_encrypted(), "Encryption was not enabled.");
70+
assert!(
71+
alice_room.encryption_state().is_state_encrypted(),
72+
"State encryption was not enabled."
73+
);
74+
6475
info!(room_id = ?alice_room.room_id(), "Alice has created and enabled encryption in the room");
6576

6677
// ... and changes the room name

0 commit comments

Comments
 (0)