From 2ace35ad6b159a2765d810a2cd674e8ffb9b8cbd Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 2 Apr 2020 17:16:06 +0200 Subject: [PATCH] add isSelfVerification helper --- src/crypto/verification/request/VerificationRequest.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/crypto/verification/request/VerificationRequest.js b/src/crypto/verification/request/VerificationRequest.js index 63c8479ef..afb0d51a4 100644 --- a/src/crypto/verification/request/VerificationRequest.js +++ b/src/crypto/verification/request/VerificationRequest.js @@ -302,6 +302,10 @@ export class VerificationRequest extends EventEmitter { return this.channel.userId; } + get isSelfVerification() { + return this._client.getUserId() === this.otherUserId; + } + /** * The id of the user that cancelled the request, * only defined when phase is PHASE_CANCELLED @@ -589,10 +593,9 @@ export class VerificationRequest extends EventEmitter { return false; } const oldEvent = this._verifier.startEvent; - const isSelfVerification = this.channel.userId === this._client.getUserId(); let oldRaceIdentifier; - if (isSelfVerification) { + if (this.isSelfVerification) { // if the verifier does not have a startEvent, // it is because it's still sending and we are on the initator side // we know we are sending a .start event because we already @@ -612,7 +615,7 @@ export class VerificationRequest extends EventEmitter { } let newRaceIdentifier; - if (isSelfVerification) { + if (this.isSelfVerification) { const newContent = newEvent.getContent(); newRaceIdentifier = newContent && newContent.from_device; } else {