You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
try to re-fetch devices before giving up on trying to heal a broken olm (#1224)
This commit is contained in:
@@ -598,6 +598,7 @@ describe("MegolmDecryption", function() {
|
|||||||
aliceClient.initCrypto(),
|
aliceClient.initCrypto(),
|
||||||
bobClient.initCrypto(),
|
bobClient.initCrypto(),
|
||||||
]);
|
]);
|
||||||
|
aliceClient._crypto.downloadKeys = async () => {};
|
||||||
const bobDevice = bobClient._crypto._olmDevice;
|
const bobDevice = bobClient._crypto._olmDevice;
|
||||||
|
|
||||||
const roomId = "!someroom";
|
const roomId = "!someroom";
|
||||||
@@ -649,6 +650,7 @@ describe("MegolmDecryption", function() {
|
|||||||
bobClient.initCrypto(),
|
bobClient.initCrypto(),
|
||||||
]);
|
]);
|
||||||
const bobDevice = bobClient._crypto._olmDevice;
|
const bobDevice = bobClient._crypto._olmDevice;
|
||||||
|
aliceClient._crypto.downloadKeys = async () => {};
|
||||||
|
|
||||||
const roomId = "!someroom";
|
const roomId = "!someroom";
|
||||||
|
|
||||||
|
@@ -1260,17 +1260,25 @@ MegolmDecryption.prototype.onRoomKeyWithheldEvent = async function(event) {
|
|||||||
this.retryDecryptionFromSender(senderKey);
|
this.retryDecryptionFromSender(senderKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const device = this._crypto._deviceList.getDeviceByIdentityKey(
|
let device = this._crypto._deviceList.getDeviceByIdentityKey(
|
||||||
content.algorithm, senderKey,
|
content.algorithm, senderKey,
|
||||||
);
|
);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
logger.info(
|
// if we don't know about the device, fetch the user's devices again
|
||||||
"Couldn't find device for identity key " + senderKey +
|
// and retry before giving up
|
||||||
": not establishing session",
|
await this._crypto.downloadKeys([sender], false);
|
||||||
|
device = this._crypto._deviceList.getDeviceByIdentityKey(
|
||||||
|
content.algorithm, senderKey,
|
||||||
);
|
);
|
||||||
await this._olmDevice.recordSessionProblem(senderKey, "no_olm", false);
|
if (!device) {
|
||||||
this.retryDecryptionFromSender(senderKey);
|
logger.info(
|
||||||
return;
|
"Couldn't find device for identity key " + senderKey +
|
||||||
|
": not establishing session",
|
||||||
|
);
|
||||||
|
await this._olmDevice.recordSessionProblem(senderKey, "no_olm", false);
|
||||||
|
this.retryDecryptionFromSender(senderKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await olmlib.ensureOlmSessionsForDevices(
|
await olmlib.ensureOlmSessionsForDevices(
|
||||||
this._olmDevice, this._baseApis, {[sender]: [device]}, false,
|
this._olmDevice, this._baseApis, {[sender]: [device]}, false,
|
||||||
|
@@ -2723,15 +2723,21 @@ Crypto.prototype._onToDeviceBadEncrypted = async function(event) {
|
|||||||
// on a current session.
|
// on a current session.
|
||||||
// Note that an undecryptable message from another device could easily be spoofed -
|
// Note that an undecryptable message from another device could easily be spoofed -
|
||||||
// is there anything we can do to mitigate this?
|
// is there anything we can do to mitigate this?
|
||||||
const device = this._deviceList.getDeviceByIdentityKey(algorithm, deviceKey);
|
let device = this._deviceList.getDeviceByIdentityKey(algorithm, deviceKey);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
logger.info(
|
// if we don't know about the device, fetch the user's devices again
|
||||||
"Couldn't find device for identity key " + deviceKey +
|
// and retry before giving up
|
||||||
": not re-establishing session",
|
await this.downloadKeys([sender], false);
|
||||||
);
|
device = this._deviceList.getDeviceByIdentityKey(algorithm, deviceKey);
|
||||||
await this._olmDevice.recordSessionProblem(deviceKey, "wedged", false);
|
if (!device) {
|
||||||
retryDecryption();
|
logger.info(
|
||||||
return;
|
"Couldn't find device for identity key " + deviceKey +
|
||||||
|
": not re-establishing session",
|
||||||
|
);
|
||||||
|
await this._olmDevice.recordSessionProblem(deviceKey, "wedged", false);
|
||||||
|
retryDecryption();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const devicesByUser = {};
|
const devicesByUser = {};
|
||||||
devicesByUser[sender] = [device];
|
devicesByUser[sender] = [device];
|
||||||
|
Reference in New Issue
Block a user