You've already forked matrix-js-sdk
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user