|
3 | 3 | use js_sys::JsString;
|
4 | 4 | use matrix_sdk_common::deserialized_responses::{VerificationLevel, WithheldCode};
|
5 | 5 | use matrix_sdk_crypto::{vodozemac, MegolmError};
|
| 6 | +use tracing::warn; |
6 | 7 | use wasm_bindgen::prelude::wasm_bindgen;
|
7 | 8 |
|
8 | 9 | /// Decryption error codes
|
@@ -73,15 +74,25 @@ impl From<MegolmError> for MegolmDecryptionError {
|
73 | 74 | MegolmError::MismatchedIdentityKeys { .. } => {
|
74 | 75 | decryption_error(DecryptionErrorCode::UnknownMessageIndex, None)
|
75 | 76 | }
|
76 |
| - MegolmError::SenderIdentityNotTrusted(VerificationLevel::VerificationViolation) => { |
77 |
| - decryption_error(DecryptionErrorCode::SenderIdentityVerificationViolation, None) |
78 |
| - } |
79 |
| - MegolmError::SenderIdentityNotTrusted(VerificationLevel::UnsignedDevice) => { |
80 |
| - decryption_error(DecryptionErrorCode::UnsignedSenderDevice, None) |
81 |
| - } |
82 |
| - MegolmError::SenderIdentityNotTrusted(VerificationLevel::None(..)) => { |
83 |
| - decryption_error(DecryptionErrorCode::UnknownSenderDevice, None) |
84 |
| - } |
| 77 | + MegolmError::SenderIdentityNotTrusted(vl) => match vl { |
| 78 | + VerificationLevel::VerificationViolation => { |
| 79 | + decryption_error(DecryptionErrorCode::SenderIdentityVerificationViolation, None) |
| 80 | + } |
| 81 | + VerificationLevel::UnsignedDevice => { |
| 82 | + decryption_error(DecryptionErrorCode::UnsignedSenderDevice, None) |
| 83 | + } |
| 84 | + VerificationLevel::None(..) => { |
| 85 | + decryption_error(DecryptionErrorCode::UnknownSenderDevice, None) |
| 86 | + } |
| 87 | + VerificationLevel::UnverifiedIdentity => { |
| 88 | + // We do not expect to find this in a MegolmError, since even at the strictest |
| 89 | + // `TrustRequirement` level, we are happy to accept events from users whose |
| 90 | + // identities we have not verified. We spit out a warning and then treat |
| 91 | + // it as a generic UTD. |
| 92 | + warn!("Unexpected verification level in megolm decryption error {}", value); |
| 93 | + decryption_error(DecryptionErrorCode::UnableToDecrypt, None) |
| 94 | + } |
| 95 | + }, |
85 | 96 | _ => decryption_error(DecryptionErrorCode::UnableToDecrypt, None),
|
86 | 97 | }
|
87 | 98 | }
|
|
0 commit comments