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

only send decrypted events to Verifier in e2ee rooms

This commit is contained in:
Bruno Windels
2019-11-18 18:30:43 +01:00
parent fbc4bd0c96
commit 180fea8ace
2 changed files with 57 additions and 7 deletions

View File

@@ -74,6 +74,7 @@ export default class VerificationBase extends EventEmitter {
this._done = false;
this._promise = null;
this._transactionTimeoutTimer = null;
this._eventsSubscription = null;
// At this point, the verification request was received so start the timeout timer.
this._resetTimer();
@@ -222,6 +223,10 @@ export default class VerificationBase extends EventEmitter {
// but no reject function. If cancel is called again, we'd error.
if (this._reject) this._reject(e);
} else {
// unsubscribe from events, this happens in _reject usually but we don't have one here
if (this._eventsSubscription) {
this._eventsSubscription = this._eventsSubscription();
}
// FIXME: this causes an "Uncaught promise" console message
// if nothing ends up chaining this promise.
this._promise = Promise.reject(e);
@@ -246,7 +251,10 @@ export default class VerificationBase extends EventEmitter {
this._done = true;
this._endTimer();
if (this.handler) {
this._baseApis.off("event", this.handler);
// these listeners are attached in Crypto.acceptVerificationDM
if (this._eventsSubscription) {
this._eventsSubscription = this._eventsSubscription();
}
}
resolve(...args);
};
@@ -254,7 +262,10 @@ export default class VerificationBase extends EventEmitter {
this._done = true;
this._endTimer();
if (this.handler) {
this._baseApis.off("event", this.handler);
// these listeners are attached in Crypto.acceptVerificationDM
if (this._eventsSubscription) {
this._eventsSubscription = this._eventsSubscription();
}
}
reject(...args);
};
@@ -295,4 +306,8 @@ export default class VerificationBase extends EventEmitter {
await this._baseApis.setDeviceVerified(userId, deviceId);
}
}
setEventsSubscription(subscription) {
this._eventsSubscription = subscription;
}
}