Skip to content

Commit

Permalink
mark request as cancelled immediately after verifier is cancelled
Browse files Browse the repository at this point in the history
in case send errors prevent us from receiving remote echo
  • Loading branch information
bwindels committed Apr 9, 2020
1 parent 00233d6 commit 1172783
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/crypto/verification/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export class VerificationBase extends EventEmitter {
this._endTimer(); // always kill the activity timer
if (!this._done) {
this.cancelled = true;
this.request.onVerifierCancelled();
if (this.userId && this.deviceId) {
// send a cancellation to the other user (if it wasn't
// cancelled by the other user)
Expand Down
12 changes: 11 additions & 1 deletion src/crypto/verification/request/VerificationRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class VerificationRequest extends EventEmitter {
this._accepting = false;
this._declining = false;
this._verifierHasFinished = false;
this._cancelled = false;
this._chosenMethod = null;
// we keep a copy of the QR Code data (including other user master key) around
// for QR reciprocate verification, to protect against
Expand Down Expand Up @@ -525,7 +526,7 @@ export class VerificationRequest extends EventEmitter {
}

const cancelEvent = this._getEventByEither(CANCEL_TYPE);
if (cancelEvent && phase() !== PHASE_DONE) {
if ((this._cancelled || cancelEvent) && phase() !== PHASE_DONE) {
transitions.push({phase: PHASE_CANCELLED, event: cancelEvent});
return transitions;
}
Expand Down Expand Up @@ -858,6 +859,15 @@ export class VerificationRequest extends EventEmitter {
return true;
}

onVerifierCancelled() {
this._cancelled = true;
// move to cancelled phase
const newTransitions = this._applyPhaseTransitions();
if (newTransitions.length) {
this._setPhase(newTransitions[newTransitions.length - 1].phase);
}
}

onVerifierFinished() {
this.channel.send("m.key.verification.done", {});
this._verifierHasFinished = true;
Expand Down

0 comments on commit 1172783

Please sign in to comment.