1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

Reinstate device blocking for simple Olm

Commit 4cde51b3 broke device blocking such that we were encrypting for all
devices, including blocked ones. Reinstate it, and add a test.
This commit is contained in:
Richard van der Hoff
2016-08-24 08:04:13 +01:00
parent ba339ffdad
commit 31e7addf2f
2 changed files with 47 additions and 30 deletions

View File

@@ -24,6 +24,9 @@ var q = require('q');
var utils = require("../utils");
var olmlib = require("../olmlib");
var DeviceInfo = require("../crypto-deviceinfo");
var DeviceVerification = DeviceInfo.DeviceVerification;
var base = require("./base");
@@ -77,21 +80,17 @@ OlmEncryption.prototype.encryptMessage = function(room, eventType, content) {
var userId = users[i];
var devices = this._crypto.getStoredDevicesForUser(userId);
for (var j = 0; j < devices.length; ++j) {
var dev = devices[j];
if (dev.blocked) {
var deviceInfo = devices[j];
var key = deviceInfo.getIdentityKey();
if (key == this._olmDevice.deviceCurve25519Key) {
// don't bother setting up session to ourself
continue;
}
for (var keyId in dev.keys) {
if (keyId.indexOf("curve25519:") === 0) {
var key = dev.keys[keyId];
// don't send to ourselves.
if (key != this._olmDevice.deviceCurve25519Key) {
participantKeys.push(key);
}
}
if (deviceInfo.verified == DeviceVerification.BLOCKED) {
// don't bother setting up sessions with blocked users
continue;
}
participantKeys.push(key);
}
}