1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

Support for marking devices as unverified

Mostly because it's useful for testing, to be honest.
This commit is contained in:
Richard van der Hoff
2016-06-09 19:05:54 +01:00
parent 7f113de790
commit 7604bcc49a

View File

@@ -547,9 +547,16 @@ MatrixClient.prototype.listDeviceKeys = function(userId) {
* @param {string} userId owner of the device * @param {string} userId owner of the device
* @param {string} deviceId unique identifier for the device * @param {string} deviceId unique identifier for the device
* *
* @param {boolean=} verified whether to mark the device as verified. defaults
* to 'true'.
*
* @fires module:client~event:MatrixClient"deviceVerified" * @fires module:client~event:MatrixClient"deviceVerified"
*/ */
MatrixClient.prototype.setDeviceVerified = function(userId, deviceId) { MatrixClient.prototype.setDeviceVerified = function(userId, deviceId, verified) {
if (verified === undefined) {
verified = true;
}
if (!this.sessionStore) { if (!this.sessionStore) {
throw new Error("End-to-End encryption disabled"); throw new Error("End-to-End encryption disabled");
} }
@@ -560,10 +567,10 @@ MatrixClient.prototype.setDeviceVerified = function(userId, deviceId) {
} }
var dev = devices[deviceId]; var dev = devices[deviceId];
if (dev.verified) { if (dev.verified === verified) {
return; return;
} }
dev.verified = true; dev.verified = verified;
this.sessionStore.storeEndToEndDevicesForUser(userId, devices); this.sessionStore.storeEndToEndDevicesForUser(userId, devices);
this.emit("deviceVerified", userId, deviceId, dev); this.emit("deviceVerified", userId, deviceId, dev);