From ee5b8748b58e8b94aef81c61c14a89c9d4227bc4 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 24 Aug 2017 13:32:19 +0100 Subject: [PATCH] Add MatrixEvent.isDecryptionFailure() --- src/models/event.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/models/event.js b/src/models/event.js index 89f574851..3a4e87f59 100644 --- a/src/models/event.js +++ b/src/models/event.js @@ -318,6 +318,19 @@ utils.extend(module.exports.MatrixEvent.prototype, { return this._decryptionPromise != null; }, + /** + * Check if this event is an encrypted event which we failed to decrypt + * + * (This implies that we might retry decryption at some point in the future) + * + * @return {boolean} True if this event is an encrypted event which we + * couldn't decrypt. + */ + isDecryptionFailure: function() { + return this._clearEvent && this._clearEvent.content && + this._clearEvent.content.msgtype === "m.bad.encrypted"; + }, + /** * Start the process of trying to decrypt this event. *