1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

add isSelfVerification helper

This commit is contained in:
Bruno Windels
2020-04-02 17:16:06 +02:00
parent b5ea8d3a78
commit 2ace35ad6b

View File

@@ -302,6 +302,10 @@ export class VerificationRequest extends EventEmitter {
return this.channel.userId; return this.channel.userId;
} }
get isSelfVerification() {
return this._client.getUserId() === this.otherUserId;
}
/** /**
* The id of the user that cancelled the request, * The id of the user that cancelled the request,
* only defined when phase is PHASE_CANCELLED * only defined when phase is PHASE_CANCELLED
@@ -589,10 +593,9 @@ export class VerificationRequest extends EventEmitter {
return false; return false;
} }
const oldEvent = this._verifier.startEvent; const oldEvent = this._verifier.startEvent;
const isSelfVerification = this.channel.userId === this._client.getUserId();
let oldRaceIdentifier; let oldRaceIdentifier;
if (isSelfVerification) { if (this.isSelfVerification) {
// if the verifier does not have a startEvent, // if the verifier does not have a startEvent,
// it is because it's still sending and we are on the initator side // 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 // we know we are sending a .start event because we already
@@ -612,7 +615,7 @@ export class VerificationRequest extends EventEmitter {
} }
let newRaceIdentifier; let newRaceIdentifier;
if (isSelfVerification) { if (this.isSelfVerification) {
const newContent = newEvent.getContent(); const newContent = newEvent.getContent();
newRaceIdentifier = newContent && newContent.from_device; newRaceIdentifier = newContent && newContent.from_device;
} else { } else {