Skip to content
Snippets Groups Projects
Commit f3553bea authored by Luke Barnard's avatar Luke Barnard
Browse files

Expose last decryption error of an event that failed to be decrypted

parent 0415f821
Branches
No related tags found
No related merge requests found
......@@ -140,6 +140,10 @@ module.exports.MatrixEvent = function MatrixEvent(
* attempt may succeed)
*/
this._retryDecryption = false;
// The last DecryptionError thrown when failing to decrypt the event, or
// null if the event never failed to decrypt.
this._lastDecryptionError = null;
};
utils.inherits(module.exports.MatrixEvent, EventEmitter);
......@@ -332,6 +336,16 @@ utils.extend(module.exports.MatrixEvent.prototype, {
this._clearEvent.content.msgtype === "m.bad.encrypted";
},
/**
* Get the last error thrown if the event failed to be decrypted.
*
* @return {module:crypto/algorithms/base.DecryptionError?} The last error
* thrown if the event failed to be decrypted or `null` if it never failed.
*/
getLastDecryptionFailureError: function() {
return this._lastDecryptionError;
},
/**
* Start the process of trying to decrypt this event.
*
......@@ -422,6 +436,8 @@ utils.extend(module.exports.MatrixEvent.prototype, {
return;
}
this._lastDecryptionError = e;
// see if we have a retry queued.
//
// NB: make sure to keep this check in the same tick of the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment