Look for existing verification requests after login

Fixes https://github.com/vector-im/riot-web/issues/13462
Requires https://github.com/matrix-org/matrix-js-sdk/pull/1405
This commit is contained in:
David Baker 2020-06-15 17:41:22 +01:00
parent 94f52c4ee2
commit 0618d82ccb

View file

@ -49,6 +49,12 @@ export class SetupEncryptionStore extends EventEmitter {
MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequest); MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequest);
MatrixClientPeg.get().on('userTrustStatusChanged', this._onUserTrustStatusChanged); MatrixClientPeg.get().on('userTrustStatusChanged', this._onUserTrustStatusChanged);
const cli = MatrixClientPeg.get();
const requestsInProgress = cli.getVerificationRequestsToDeviceInProgress(cli.getUserId());
if (requestsInProgress.length) {
this._setActiveVerificationRequest(requestsInProgress[0]);
}
this.fetchKeyInfo(); this.fetchKeyInfo();
} }
@ -168,16 +174,8 @@ export class SetupEncryptionStore extends EventEmitter {
} }
} }
onVerificationRequest = async (request) => { onVerificationRequest = (request) => {
if (request.otherUserId !== MatrixClientPeg.get().getUserId()) return; this._setActiveVerificationRequest(request);
if (this.verificationRequest) {
this.verificationRequest.off("change", this.onVerificationRequestChange);
}
this.verificationRequest = request;
await request.accept();
request.on("change", this.onVerificationRequestChange);
this.emit("update");
} }
onVerificationRequestChange = async () => { onVerificationRequestChange = async () => {
@ -218,4 +216,16 @@ export class SetupEncryptionStore extends EventEmitter {
// async - ask other clients for keys, if necessary // async - ask other clients for keys, if necessary
MatrixClientPeg.get()._crypto.cancelAndResendAllOutgoingKeyRequests(); MatrixClientPeg.get()._crypto.cancelAndResendAllOutgoingKeyRequests();
} }
async _setActiveVerificationRequest(request) {
if (request.otherUserId !== MatrixClientPeg.get().getUserId()) return;
if (this.verificationRequest) {
this.verificationRequest.off("change", this.onVerificationRequestChange);
}
this.verificationRequest = request;
await request.accept();
request.on("change", this.onVerificationRequestChange);
this.emit("update");
}
} }