Skip to content

Commit

Permalink
crypto: rename UtdCause::Membership
Browse files Browse the repository at this point in the history
Before we do any more work here, give this variant a better name
  • Loading branch information
richvdh committed Oct 21, 2024
1 parent dac9f06 commit 1bc35af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions crates/matrix-sdk-crypto/src/types/events/utd_cause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub enum UtdCause {
#[default]
Unknown = 0,

/// This event was sent when we were not a member of the room (or invited),
/// so it is impossible to decrypt (without MSC3061).
Membership = 1,
/// We are missing the keys for this event, and the event was sent when we
/// were not a member of the room (or invited).
SentBeforeWeJoined = 1,
//
// TODO: Other causes for UTDs. For example, this message is device-historical, information
// extracted from the WithheldCode in the MissingRoomKey object, or various types of Olm
Expand Down Expand Up @@ -64,7 +64,7 @@ impl UtdCause {
if let Ok(Some(unsigned)) = raw_event.get_field::<UnsignedWithMembership>("unsigned") {
if let Membership::Leave = unsigned.membership {
// We were not a member - this is the cause of the UTD
return UtdCause::Membership;
return UtdCause::SentBeforeWeJoined;
}
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ mod tests {
// until we have MSC3061.
assert_eq!(
UtdCause::determine(Some(&raw_event(json!({ "unsigned": { "membership": "leave" } })))),
UtdCause::Membership
UtdCause::SentBeforeWeJoined
);
}

Expand All @@ -143,7 +143,7 @@ mod tests {
UtdCause::determine(Some(&raw_event(
json!({ "unsigned": { "io.element.msc4115.membership": "leave" } })
))),
UtdCause::Membership
UtdCause::SentBeforeWeJoined
);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/tests/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ async fn test_utd_cause_for_nonmember_event_is_found() {
TimelineItemContent::UnableToDecrypt(EncryptedMessage::MegolmV1AesSha2 { cause, .. }) =
event.content()
);
assert_eq!(*cause, UtdCause::Membership);
assert_eq!(*cause, UtdCause::SentBeforeWeJoined);
}

#[async_test]
Expand All @@ -516,7 +516,7 @@ async fn test_utd_cause_for_nonmember_event_is_found_unstable_prefix() {
TimelineItemContent::UnableToDecrypt(EncryptedMessage::MegolmV1AesSha2 { cause, .. }) =
event.content()
);
assert_eq!(*cause, UtdCause::Membership);
assert_eq!(*cause, UtdCause::SentBeforeWeJoined);
}

#[async_test]
Expand Down

0 comments on commit 1bc35af

Please sign in to comment.