Skip to content

Commit 54533e7

Browse files
authored
Merge pull request #239 from matrix-org/rav/olm_decryption_info
Expose EncryptionInfo on decrypted to-device events
2 parents 3b00d29 + b88cc8c commit 54533e7

File tree

7 files changed

+211
-82
lines changed

7 files changed

+211
-82
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UNRELEASED
22

3-
- Update matrix-rusk-sdk to `022068996`, which includes:
3+
- Update matrix-rusk-sdk to `0f73ffde6`, which includes:
44

55
- Send stable identifier `sender_device_keys` for MSC4147 (Including device
66
keys with Olm-encrypted events).

Cargo.lock

Lines changed: 23 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ futures-util = "0.3.27"
6565
getrandom = { version = "0.3.0", features = ["wasm_js"] }
6666
http = "1.1.0"
6767
js-sys = "0.3.49"
68-
matrix-sdk-common = { git = "https://github.com/matrix-org/matrix-rust-sdk", rev = "022068996", features = ["js"] }
69-
matrix-sdk-indexeddb = { git = "https://github.com/matrix-org/matrix-rust-sdk", rev = "022068996", default-features = false, features = ["e2e-encryption"] }
70-
matrix-sdk-qrcode = { git = "https://github.com/matrix-org/matrix-rust-sdk", rev = "022068996", optional = true }
68+
matrix-sdk-common = { git = "https://github.com/matrix-org/matrix-rust-sdk", rev = "0f73ffde6", features = ["js"] }
69+
matrix-sdk-indexeddb = { git = "https://github.com/matrix-org/matrix-rust-sdk", rev = "0f73ffde6", default-features = false, features = ["e2e-encryption"] }
70+
matrix-sdk-qrcode = { git = "https://github.com/matrix-org/matrix-rust-sdk", rev = "0f73ffde6", optional = true }
7171
serde = "1.0.91"
7272
serde_json = "1.0.91"
7373
serde-wasm-bindgen = "0.6.5"
@@ -84,7 +84,7 @@ vergen-gitcl = { version = "1.0.0", features = ["build"] }
8484

8585
[dependencies.matrix-sdk-crypto]
8686
git = "https://github.com/matrix-org/matrix-rust-sdk"
87-
rev = "022068996"
87+
rev = "0f73ffde6"
8888
default-features = false
8989
features = ["js", "automatic-room-key-forwarding"]
9090

src/machine.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl OlmMachine {
362362

363363
Ok(processed_to_device_events
364364
.into_iter()
365-
.map(processed_to_device_event_to_js_value)
365+
.filter_map(processed_to_device_event_to_js_value)
366366
.collect::<Vec<_>>())
367367
}))
368368
}
@@ -512,7 +512,14 @@ impl OlmMachine {
512512
.await
513513
.map_err(MegolmDecryptionError::from)?
514514
.into();
515-
Ok(responses::DecryptedRoomEvent::from(room_event))
515+
516+
responses::DecryptedRoomEvent::try_from(room_event).map_err(|e: anyhow::Error| {
517+
// This happens if we somehow encounter a room event whose encryption info we
518+
// don't understand (e.g., it is encrypted with Olm rather than
519+
// Megolm). That seems pretty unlikely. If it happens, let's
520+
// just treat it as a generic UTD.
521+
MegolmDecryptionError::unable_to_decrypt(format!("{e:#}"))
522+
})
516523
}))
517524
}
518525

@@ -545,7 +552,7 @@ impl OlmMachine {
545552
Ok(future_to_promise(async move {
546553
let encryption_info =
547554
me.get_room_event_encryption_info(&event, room_id.as_ref()).await?;
548-
Ok(responses::EncryptionInfo::from(encryption_info))
555+
Ok(responses::EncryptionInfo::try_from(encryption_info)?)
549556
}))
550557
}
551558

0 commit comments

Comments
 (0)