Skip to content

Commit 2758019

Browse files
committed
chore: fixes and formatting
Signed-off-by: Skye Elliot <[email protected]>
1 parent e4f0477 commit 2758019

File tree

7 files changed

+26
-13
lines changed

7 files changed

+26
-13
lines changed

crates/matrix-sdk-base/src/response_processors/room/msc4186/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ pub async fn update_any_room(
118118
ambiguity_cache,
119119
&mut new_user_ids,
120120
state_store,
121+
#[cfg(feature = "e2e-encryption")]
121122
e2ee.clone(),
122123
)
123124
.await?;

crates/matrix-sdk-base/src/response_processors/room/sync_v2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ pub async fn update_left_room(
192192
ambiguity_cache,
193193
&mut (),
194194
state_store,
195+
#[cfg(feature = "e2e-encryption")]
195196
e2ee.clone(),
196197
)
197198
.await?;
@@ -206,6 +207,7 @@ pub async fn update_left_room(
206207
ambiguity_cache,
207208
&mut (),
208209
state_store,
210+
#[cfg(feature = "e2e-encryption")]
209211
e2ee.clone(),
210212
)
211213
.await?;

crates/matrix-sdk-base/src/response_processors/state_events.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ pub mod sync {
158158
room_info.handle_state_event(
159159
&room_event
160160
.event
161-
// TODO: UNSAFE CAST - someone evil could encrypt something that isn't a state event.
161+
// TODO: UNSAFE CAST - someone evil could encrypt something that
162+
// isn't a state event.
162163
.deserialize_as_unchecked::<AnySyncStateEvent>()
163164
.unwrap(),
164165
);

crates/matrix-sdk-base/src/room/encryption.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ impl Room {
3333
#[derive(Debug)]
3434
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
3535
pub enum EncryptionState {
36-
/// The room is encrypted.
36+
/// The room is encrypted, not including state events.
3737
Encrypted,
3838

39-
/// The room is encrypted, along with state events.
40-
EncryptedState,
39+
/// The room is encrypted, including state events.
40+
StateEncrypted,
4141

4242
/// The room is not encrypted.
4343
NotEncrypted,
@@ -48,9 +48,16 @@ pub enum EncryptionState {
4848
}
4949

5050
impl EncryptionState {
51-
/// Check whether `EncryptionState` is [`Encrypted`][Self::Encrypted].
51+
/// Check whether `EncryptionState` is [`Encrypted`][Self::Encrypted] or
52+
/// [`StateEncrypted`][Self::StateEncrypted].
5253
pub fn is_encrypted(&self) -> bool {
53-
matches!(self, Self::Encrypted | Self::EncryptedState)
54+
matches!(self, Self::Encrypted | Self::StateEncrypted)
55+
}
56+
57+
/// Check whether `EncryptionState` is
58+
/// [`StateEncrypted`][Self::StateEncrypted].
59+
pub fn is_state_encrypted(&self) -> bool {
60+
matches!(self, Self::StateEncrypted)
5461
}
5562

5663
/// Check whether `EncryptionState` is [`Unknown`][Self::Unknown].
@@ -153,12 +160,12 @@ mod tests {
153160
fn test_encryption_state() {
154161
assert!(EncryptionState::Unknown.is_unknown());
155162
assert!(EncryptionState::Encrypted.is_unknown().not());
156-
assert!(EncryptionState::EncryptedState.is_unknown().not());
163+
assert!(EncryptionState::StateEncrypted.is_unknown().not());
157164
assert!(EncryptionState::NotEncrypted.is_unknown().not());
158165

159166
assert!(EncryptionState::Unknown.is_encrypted().not());
160167
assert!(EncryptionState::Encrypted.is_encrypted());
161-
assert!(EncryptionState::EncryptedState.is_encrypted());
168+
assert!(EncryptionState::StateEncrypted.is_encrypted());
162169
assert!(EncryptionState::NotEncrypted.is_encrypted().not());
163170
}
164171
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl<'a> IntoFuture for SendStateEventRaw<'a> {
420420
let mut state_key = state_key.to_owned();
421421

422422
#[cfg(feature = "e2e-encryption")]
423-
if room.latest_encryption_state().await?.is_encrypted() {
423+
if room.latest_encryption_state().await?.is_state_encrypted() {
424424
if matches!(
425425
event_type,
426426
"m.room.create"

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ impl Room {
647647
SyncStateEvent::Original(_)
648648
)))
649649
) {
650-
// Cast safety: The state key is not used during decryption, and the types overlap sufficiently.
650+
// Cast safety: The state key is not used during decryption, and the types
651+
// overlap sufficiently.
651652
if let Ok(event) = self.decrypt_event(event.cast_ref_unchecked(), push_ctx).await {
652653
return event;
653654
}
@@ -811,7 +812,8 @@ impl Room {
811812
/// Request to update the encryption state for this room.
812813
///
813814
/// It does nothing if the encryption state is already
814-
/// [`EncryptionState::Encrypted`], [`EncryptionState::EncryptedState`], or [`EncryptionState::NotEncrypted`].
815+
/// [`EncryptionState::Encrypted`], [`EncryptionState::StateEncrypted`], or
816+
/// [`EncryptionState::NotEncrypted`].
815817
pub async fn request_encryption_state(&self) -> Result<()> {
816818
if !self.inner.encryption_state().is_unknown() {
817819
return Ok(());

crates/matrix-sdk/src/test_utils/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ macro_rules! assert_decrypted_message_eq {
266266
}};
267267
}
268268

269-
/// Given a [`TimelineEvent`], assert that the event was decrypted and that its content
270-
/// matches the given pattern.
269+
/// Given a [`TimelineEvent`], assert that the event is an encrypted state
270+
/// event, and that its content matches the given pattern via a let binding.
271271
#[macro_export]
272272
macro_rules! assert_let_decrypted_state_event_content {
273273
($pat:pat = $event:expr, $($msg:tt)*) => {

0 commit comments

Comments
 (0)