1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-02 17:02:31 +03:00

Address review comments

Avoid gut-wrenching properties on IncomingRoomKeyRequest.
This commit is contained in:
Richard van der Hoff
2017-06-05 16:07:38 +01:00
parent 2daa39520a
commit 1664312c80

View File

@@ -1138,7 +1138,7 @@ Crypto.prototype._processReceivedRoomKeyRequests = function() {
continue; continue;
} }
req._shareCallback = () => { req.share = () => {
decryptor.shareKeysWithDevice(req); decryptor.shareKeysWithDevice(req);
}; };
@@ -1244,6 +1244,9 @@ Crypto.prototype._signObject = function(obj) {
* @property {string} deviceId device requesting the key * @property {string} deviceId device requesting the key
* @property {string} requestId unique id for the request * @property {string} requestId unique id for the request
* @property {RoomKeyRequestBody} requestBody * @property {RoomKeyRequestBody} requestBody
* @property {Function} share callback which, when called, will ask
* the relevant crypto algorithm implementation to share the keys for
* this request.
*/ */
class IncomingRoomKeyRequest { class IncomingRoomKeyRequest {
constructor(event) { constructor(event) {
@@ -1253,19 +1256,9 @@ class IncomingRoomKeyRequest {
this.deviceId = content.requesting_device_id; this.deviceId = content.requesting_device_id;
this.requestId = content.request_id; this.requestId = content.request_id;
this.requestBody = content.body || {}; this.requestBody = content.body || {};
this._shareCallback = null; this.share = () => {
} throw new Error("don't know how to share keys for this request yet");
};
/**
* Ask the relevant crypto algorithm implementation to share the keys for
* this request
*/
share() {
if (this._shareCallback) {
this._shareCallback();
return;
}
throw new Error("don't know how to share keys for this request yet");
} }
} }