diff --git a/src/crypto/index.js b/src/crypto/index.js index d43c27d1d..d94ba0aa2 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -2503,6 +2503,7 @@ Crypto.prototype._handleVerificationEvent = async function( if (!request) { return; } + event.setVerificationRequest(request); isNewRequest = true; if (!requestsByTxnId) { requestsByTxnId = new Map(); diff --git a/src/models/event.js b/src/models/event.js index 0d1b7048b..34af1ecfe 100644 --- a/src/models/event.js +++ b/src/models/event.js @@ -155,6 +155,12 @@ module.exports.MatrixEvent = function MatrixEvent( * attempt may succeed) */ this._retryDecryption = false; + + /* If the event is a `m.key.verification.request` (or to_device `m.key.verification.start`) event, + * `Crypto` will set this the `VerificationRequest` for the event + * so it can be easily accessed from the timeline. + */ + this.verificationRequest = null; }; utils.inherits(module.exports.MatrixEvent, EventEmitter); @@ -1055,6 +1061,10 @@ utils.extend(module.exports.MatrixEvent.prototype, { encrypted: this.event, }; }, + + setVerificationRequest: function(request) { + this.verificationRequest = request; + }, });