Skip to content

Commit c2f50fd

Browse files
andybalaampoljar
authored andcommitted
doc(crypto): Attempt to explain what handle_to_device_event does and make all types explicit
1 parent dc90c77 commit c2f50fd

File tree

1 file changed

+16
-2
lines changed
  • crates/matrix-sdk-crypto/src/machine

1 file changed

+16
-2
lines changed

crates/matrix-sdk-crypto/src/machine/mod.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,10 +1328,16 @@ impl OlmMachine {
13281328
self.inner.verification_machine.get_requests(user_id)
13291329
}
13301330

1331+
/// Given a to-device event that has either been decrypted or arrived in
1332+
/// plaintext, handle it.
1333+
///
1334+
/// Here, we only process events that are allowed to arrive in plaintext.
13311335
async fn handle_to_device_event(&self, changes: &mut Changes, event: &ToDeviceEvents) {
13321336
use crate::types::events::ToDeviceEvents::*;
13331337

13341338
match event {
1339+
// These are handled here because we accept them either plaintext or
1340+
// encrypted
13351341
RoomKeyRequest(e) => self.inner.key_request_machine.receive_incoming_key_request(e),
13361342
SecretRequest(e) => self.inner.key_request_machine.receive_incoming_secret_request(e),
13371343
RoomKeyWithheld(e) => self.add_withheld_info(changes, e),
@@ -1345,8 +1351,16 @@ impl OlmMachine {
13451351
| KeyVerificationStart(..) => {
13461352
self.handle_verification_event(event).await;
13471353
}
1348-
Dummy(_) | RoomKey(_) | ForwardedRoomKey(_) | RoomEncrypted(_) => {}
1349-
_ => {}
1354+
1355+
// We don't process custom or dummy events at all
1356+
Custom(_) | Dummy(_) => {}
1357+
1358+
// Encrypted events are handled elsewhere
1359+
RoomEncrypted(_) => {}
1360+
1361+
// These are handled in `handle_decrypted_to_device_event` because we
1362+
// only accept them if they arrive encrypted.
1363+
SecretSend(_) | RoomKey(_) | ForwardedRoomKey(_) => {}
13501364
}
13511365
}
13521366

0 commit comments

Comments
 (0)