1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-19 10:22:30 +03:00

Retry decryption after receiving keys

m.room_keys may arrive after the messages themselves, so allow events to be
decrypted after the event (haha).
This commit is contained in:
Richard van der Hoff
2016-11-14 15:05:49 +00:00
parent 1a03e534bd
commit a5d857945a
2 changed files with 63 additions and 2 deletions

View File

@@ -21,6 +21,10 @@ limitations under the License.
* @module models/event
*/
var EventEmitter = require("events").EventEmitter;
var utils = require('../utils.js');
/**
* Enum for event statuses.
* @readonly
@@ -79,8 +83,10 @@ module.exports.MatrixEvent = function MatrixEvent(
this._keysProved = {};
this._keysClaimed = {};
};
utils.inherits(module.exports.MatrixEvent, EventEmitter);
module.exports.MatrixEvent.prototype = {
utils.extend(module.exports.MatrixEvent.prototype, {
/**
* Get the event_id for this event.
@@ -251,6 +257,7 @@ module.exports.MatrixEvent.prototype = {
this._clearEvent = clearEvent;
this._keysProved = keysProved || {};
this._keysClaimed = keysClaimed || {};
this.emit("Event.decrypted", this);
},
/**
@@ -367,7 +374,7 @@ module.exports.MatrixEvent.prototype = {
setPushActions: function(pushActions) {
this._pushActions = pushActions;
},
};
});
/* http://matrix.org/docs/spec/r0.0.1/client_server.html#redactions says:
@@ -408,3 +415,15 @@ var _REDACT_KEEP_CONTENT_MAP = {
},
'm.room.aliases': {'aliases': 1},
};
/**
* Fires when an event is decrypted
*
* @event module:models/event.MatrixEvent#"Event.decrypted"
*
* @param {module:models/event.MatrixEvent} event
* The matrix event which has been decrypted
*/