Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Avoid gut-wrenching properties on IncomingRoomKeyRequest.
  • Loading branch information
richvdh committed Jun 5, 2017
1 parent 2daa395 commit 1664312
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ Crypto.prototype._processReceivedRoomKeyRequests = function() {
continue;
}

req._shareCallback = () => {
req.share = () => {
decryptor.shareKeysWithDevice(req);
};

Expand Down Expand Up @@ -1244,6 +1244,9 @@ Crypto.prototype._signObject = function(obj) {
* @property {string} deviceId device requesting the key
* @property {string} requestId unique id for the request
* @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 {
constructor(event) {
Expand All @@ -1253,19 +1256,9 @@ class IncomingRoomKeyRequest {
this.deviceId = content.requesting_device_id;
this.requestId = content.request_id;
this.requestBody = content.body || {};
this._shareCallback = null;
}

/**
* 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");
this.share = () => {
throw new Error("don't know how to share keys for this request yet");
};
}
}

Expand Down

0 comments on commit 1664312

Please sign in to comment.