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: Introduce EncryptionState #4777

Merged
merged 7 commits into from
Mar 11, 2025

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Mar 10, 2025

This patch introduces the new EncryptionState to represent the 3
possible states: Encrypted, NotEncrypted or Unknown. All the
is_encrypted methods have been replaced by encryption_state.
The most noticable change is in matrix_sdk::Room where async fn is_encrypted(&self) -> Result<bool> has been replaced by fn fn encryption_state(&self) -> EncryptionState. However, a new async fn latest_encryption_state(&self) -> Result<EncryptionState> method
“restores” the previous behaviour by calling request_encryption_state
if necessary.

The idea is that the caller is now responsible to call
request_encryption_state if desired, or use latest_encryption_state
to automate the call if necessary. encryption_state is now non-async
and infallible everywhere.

matrix-sdk-ffi has been updated but no methods have been added for
the moment.


@Hywan Hywan force-pushed the feat-base-encryption-state branch from 8019667 to 69e4edd Compare March 10, 2025 16:24
@Hywan Hywan requested a review from poljar March 10, 2025 16:25
@Hywan Hywan marked this pull request as ready for review March 10, 2025 16:25
@Hywan Hywan requested a review from a team as a code owner March 10, 2025 16:25
@Hywan Hywan force-pushed the feat-base-encryption-state branch 2 times, most recently from c02659c to cf7e678 Compare March 10, 2025 16:37
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.37%. Comparing base (ea8664c) to head (3c6ae5a).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4777      +/-   ##
==========================================
- Coverage   86.38%   86.37%   -0.02%     
==========================================
  Files         291      291              
  Lines       34293    34303      +10     
==========================================
+ Hits        29624    29629       +5     
- Misses       4669     4674       +5     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Looks good, you left in a merge conflict marker which we should get rid of, but that's about it.

Comment on lines +1571 to +1577
if !self.encryption_state_synced {
EncryptionState::Unknown
} else if self.base_info.encryption.is_some() {
EncryptionState::Encrypted
} else {
EncryptionState::NotEncrypted
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would probably be nice to replace encryption_state_synced and base_info.encryptionwith EncryptionState where Encrypted keeps the m.room.encryption content as associated data.

But that's probably something for a different PR and might not even be worth the trouble.

Copy link
Member Author

@Hywan Hywan Mar 11, 2025

Choose a reason for hiding this comment

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

Talked about that in a meeting and agreed to address that in another PR.

@Hywan Hywan force-pushed the feat-base-encryption-state branch 3 times, most recently from 7460970 to 45ae5f5 Compare March 11, 2025 10:24
Hywan added 5 commits March 11, 2025 11:27
This patch introduces the new `EncryptionState` to represent the 3
possible states: `Encrypted`, `NotEncrypted` or `Unknown`. All the
`is_encrypted` methods have been replaced by `encryption_state`.
The most noticable change is in `matrix_sdk::Room` where `async fn
is_encrypted(&self) -> Result<bool>` has been replaced by `fn fn
encryption_state(&self) -> EncryptionState`. However, a new `async
fn latest_encryption_state(&self) -> Result<EncryptionState>` method
“restores” the previous behaviour by calling `request_encryption_state`
if necessary.

The idea is that the caller is now responsible to call
`request_encryption_state` if desired, or use `latest_encryption_state`
to automate the call if necessary. `encryption_state` is now non-async
and infallible everywhere.

`matrix-sdk-ffi` has been updated but no methods have been added for
the moment.
@Hywan Hywan force-pushed the feat-base-encryption-state branch 2 times, most recently from d007455 to 161eb8d Compare March 11, 2025 10:59
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.

2 participants