[Client] Enhanced error handling in decryptToDeviceEvent

This commit is contained in:
Christian Pauly 2020-03-23 08:51:14 +01:00
parent ee3489561e
commit e9c0ec8511
1 changed files with 6 additions and 1 deletions

View File

@ -1603,8 +1603,13 @@ class Client {
/// Try to decrypt a ToDeviceEvent encrypted with olm.
ToDeviceEvent decryptToDeviceEvent(ToDeviceEvent toDeviceEvent) {
if (toDeviceEvent.type != "m.room.encrypted") {
print(
"[LibOlm] Warning! Tried to decrypt a not-encrypted to-device-event");
return toDeviceEvent;
}
if (toDeviceEvent.content["algorithm"] != "m.olm.v1.curve25519-aes-sha2") {
throw ("Unknown algorithm: ${toDeviceEvent.content["algorithm"]}");
throw ("Unknown algorithm: ${toDeviceEvent.content}");
}
if (!toDeviceEvent.content["ciphertext"].containsKey(identityKey)) {
throw ("The message isn't sent for this device");