You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Handle lack of one-time keys better
If a device had run out of one-time keys, we would send it an empty to_device event, which it would then fail to decrypt with a "Not included in recipients", which is all a bit pointless.
This commit is contained in:
@@ -208,10 +208,10 @@ MegolmEncryption.prototype._shareKeyWithDevices = function(session_id, shareMap)
|
||||
}
|
||||
|
||||
var devicesToShareWith = shareMap[userId];
|
||||
var deviceInfos = devicemap[userId];
|
||||
var sessionResults = devicemap[userId];
|
||||
|
||||
for (var deviceId in deviceInfos) {
|
||||
if (!deviceInfos.hasOwnProperty(deviceId)) {
|
||||
for (var deviceId in sessionResults) {
|
||||
if (!sessionResults.hasOwnProperty(deviceId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -222,11 +222,27 @@ MegolmEncryption.prototype._shareKeyWithDevices = function(session_id, shareMap)
|
||||
continue;
|
||||
}
|
||||
|
||||
var sessionResult = sessionResults[deviceId];
|
||||
if (!sessionResult.sessionId) {
|
||||
// no session with this device, probably because there
|
||||
// were no one-time keys.
|
||||
//
|
||||
// we could send them a to_device message anyway, as a
|
||||
// signal that they have missed out on the key sharing
|
||||
// message because of the lack of keys, but there's not
|
||||
// much point in that really; it will mostly serve to clog
|
||||
// up to_device inboxes.
|
||||
//
|
||||
// ensureOlmSessionsForUsers has already done the logging,
|
||||
// so just skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(
|
||||
"sharing keys with device " + userId + ":" + deviceId
|
||||
);
|
||||
|
||||
var deviceInfo = deviceInfos[deviceId].device;
|
||||
var deviceInfo = sessionResult.device;
|
||||
|
||||
if (!contentMap[userId]) {
|
||||
contentMap[userId] = {};
|
||||
|
||||
Reference in New Issue
Block a user