Skip to content

Conversation

kaylendog
Copy link
Contributor

@kaylendog kaylendog commented Aug 20, 2025

This fixes a small issue encountered while developing the integration test for encrypted state events. If the first sync response received from the server after enabling encryption does not contain the m.room.encryption event, the client will report the encryption state as unknown, even if the next sync response does contain the event.

  • Modify Room::enable_encryption_inner to spin on the room encryption state, rather than bailing after the first sync response is received.

Signed-off-by: Skye Elliot

@kaylendog kaylendog self-assigned this Aug 20, 2025
@kaylendog kaylendog marked this pull request as ready for review August 20, 2025 11:56
@kaylendog kaylendog requested a review from a team as a code owner August 20, 2025 11:56
@kaylendog kaylendog requested review from stefanceriu and removed request for a team August 20, 2025 11:56
Copy link

codecov bot commented Aug 20, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.64%. Comparing base (7adaf7b) to head (24502d2).
⚠️ Report is 19 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/room/mod.rs 80.00% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5559   +/-   ##
=======================================
  Coverage   88.63%   88.64%           
=======================================
  Files         340      340           
  Lines       95102    95112   +10     
  Branches    95102    95112   +10     
=======================================
+ Hits        84298    84308   +10     
- Misses       6616     6617    +1     
+ Partials     4188     4187    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented Aug 20, 2025

CodSpeed Performance Report

Merging #5559 will not alter performance

Comparing kaylendog/encrypt-poll-sync (24502d2) with main (b6433de)

Summary

✅ 37 untouched benchmarks

Fixes Room::enable_encryption_inner to break out of polling the
encryption state when it becomes known, rather than just encrypted.
@stefanceriu
Copy link
Member

Okay, now this makes sense to me but I would still like somebody from the crypto team to have a quick look.

@stefanceriu stefanceriu requested review from a team and richvdh and removed request for a team August 20, 2025 13:01
@kaylendog kaylendog force-pushed the kaylendog/encrypt-poll-sync branch from b4a0220 to 24502d2 Compare August 21, 2025 14:43
Comment on lines +1934 to 1952
// If encryption was enabled, return.
#[cfg(not(feature = "experimental-encrypted-state-events"))]
if res.is_ok() && self.inner.encryption_state().is_encrypted() {
debug!("room successfully marked as encrypted");
return Ok(());
}

self.client.state_store().save_changes(&changes).await?;
self.set_room_info(room_info, RoomInfoNotableUpdateReasons::empty());
} else {
// If encryption with state event encryption was enabled, return.
#[cfg(feature = "experimental-encrypted-state-events")]
if res.is_ok() && {
if encrypted_state_events {
self.inner.encryption_state().is_state_encrypted()
} else {
self.inner.encryption_state().is_encrypted()
}
} {
debug!("room successfully marked as encrypted");
return Ok(());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might belong in its own PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean, separate the "poll for 3 seconds" part from the "make it support encrypted state" part? Yes, a separate PR would be optimal, but I think it's fine in practice.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 lgtm

@richvdh richvdh merged commit fffdd34 into main Aug 21, 2025
52 checks passed
@richvdh richvdh deleted the kaylendog/encrypt-poll-sync branch August 21, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants