From a7de5753160ecf1cc657a963493131f386e655d3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 6 Mar 2020 16:50:39 +0100 Subject: [PATCH 1/3] use crypto.verification.request even when xsign is disabled --- src/components/structures/MatrixChat.js | 41 +++++++++++++------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index bc11e66d2c..e4af503b46 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1495,26 +1495,29 @@ export default createReactClass({ } }); - if (SettingsStore.isFeatureEnabled("feature_cross_signing")) { - cli.on("crypto.verification.request", request => { - if (request.pending) { - ToastStore.sharedInstance().addOrReplaceToast({ - key: 'verifreq_' + request.channel.transactionId, - title: _t("Verification Request"), - icon: "verification", - props: {request}, - component: sdk.getComponent("toasts.VerificationRequestToast"), - }); - } - }); - } else { - cli.on("crypto.verification.start", (verifier) => { - const IncomingSasDialog = sdk.getComponent("views.dialogs.IncomingSasDialog"); - Modal.createTrackedDialog('Incoming Verification', '', IncomingSasDialog, { - verifier, + cli.on("crypto.verification.request", request => { + const isFlagOn = SettingsStore.isFeatureEnabled("feature_cross_signing"); + + if (!isFlagOn && !request.channel.deviceId) { + request.cancel({code: "m.invalid_message", reason: "This client has cross-signing disabled"}); + return; + } + + if (request.pending) { + ToastStore.sharedInstance().addOrReplaceToast({ + key: 'verifreq_' + request.channel.transactionId, + title: _t("Verification Request"), + icon: "verification", + props: {request}, + component: sdk.getComponent("toasts.VerificationRequestToast"), + }); + } else if (request.started) { + const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog"); + Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, { + verificationRequest: request, }, null, /* priority = */ false, /* static = */ true); - }); - } + } + }); // Fire the tinter right on startup to ensure the default theme is applied // A later sync can/will correct the tint to be the right value for the user const colorScheme = SettingsStore.getValue("roomColor"); From f8ef5bb6a58a95969dfd181a6e997f882ce28514 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 6 Mar 2020 17:20:08 +0100 Subject: [PATCH 2/3] check .started first as it can be both .started and pending --- src/components/structures/MatrixChat.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index e4af503b46..87b0f6773f 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1503,7 +1503,12 @@ export default createReactClass({ return; } - if (request.pending) { + if (request.started) { + const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog"); + Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, { + verificationRequest: request, + }, null, /* priority = */ false, /* static = */ true); + } else if (request.pending) { ToastStore.sharedInstance().addOrReplaceToast({ key: 'verifreq_' + request.channel.transactionId, title: _t("Verification Request"), @@ -1511,11 +1516,6 @@ export default createReactClass({ props: {request}, component: sdk.getComponent("toasts.VerificationRequestToast"), }); - } else if (request.started) { - const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog"); - Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, { - verificationRequest: request, - }, null, /* priority = */ false, /* static = */ true); } }); // Fire the tinter right on startup to ensure the default theme is applied From b0617f10e82a5c60258846e69b97abb877c49e63 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 6 Mar 2020 17:22:56 +0100 Subject: [PATCH 3/3] stick to IncomingSasDialog as VerificationRequestDialog doesn't show sender yet, makes e2e tests fail --- src/components/structures/MatrixChat.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 87b0f6773f..a0b9a8fe57 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1503,10 +1503,10 @@ export default createReactClass({ return; } - if (request.started) { - const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog"); - Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, { - verificationRequest: request, + if (request.verifier) { + const IncomingSasDialog = sdk.getComponent("views.dialogs.IncomingSasDialog"); + Modal.createTrackedDialog('Incoming Verification', '', IncomingSasDialog, { + verifier: request.verifier, }, null, /* priority = */ false, /* static = */ true); } else if (request.pending) { ToastStore.sharedInstance().addOrReplaceToast({