From 69e624df4151a9dc66f0a474e093c4b37b2fa519 Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 12 Oct 2020 17:10:22 +0200 Subject: [PATCH 1/3] Cross signing: we should not show the verify with other sessions when there is not --- .../VerificationBottomSheetViewModel.kt | 12 +++++-- .../request/VerificationRequestController.kt | 32 ++++++++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt index 3c00478ab0..e65fb6042b 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -76,7 +76,8 @@ data class VerificationBottomSheetViewState( val userWantsToCancel: Boolean = false, val userThinkItsNotHim: Boolean = false, val quadSContainsSecrets: Boolean = true, - val quadSHasBeenReset: Boolean = false + val quadSHasBeenReset: Boolean = false, + val hasAnyOtherSession: Boolean = false ) : MvRxState class VerificationBottomSheetViewModel @AssistedInject constructor( @@ -119,6 +120,12 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( session.cryptoService().verificationService().getExistingTransaction(args.otherUserId, it) as? QrCodeVerificationTransaction } + val hasAnyOtherSession = session.cryptoService() + .getCryptoDeviceInfo(session.myUserId) + .any { + it.deviceId != session.sessionParams.deviceId + } + setState { copy( otherUserMxItem = userItem?.toMatrixItem(), @@ -130,7 +137,8 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( roomId = args.roomId, isMe = args.otherUserId == session.myUserId, currentDeviceCanCrossSign = session.cryptoService().crossSigningService().canCrossSign(), - quadSContainsSecrets = session.sharedSecretStorageService.isRecoverySetup() + quadSContainsSecrets = session.sharedSecretStorageService.isRecoverySetup(), + hasAnyOtherSession = hasAnyOtherSession ) } diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt index 3f4c3120e7..1b2c32a7e4 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt @@ -52,25 +52,33 @@ class VerificationRequestController @Inject constructor( val matrixItem = viewState?.otherUserMxItem ?: return if (state.selfVerificationMode) { - bottomSheetVerificationNoticeItem { - id("notice") - notice(stringProvider.getString(R.string.verification_open_other_to_verify)) - } + if (state.hasAnyOtherSession) { - bottomSheetSelfWaitItem { - id("waiting") - } + bottomSheetVerificationNoticeItem { + id("notice") + notice(stringProvider.getString(R.string.verification_open_other_to_verify)) + } - dividerItem { - id("sep") + bottomSheetSelfWaitItem { + id("waiting") + } + + dividerItem { + id("sep") + } } if (state.quadSContainsSecrets) { + val subtitle = if (state.hasAnyOtherSession) { + stringProvider.getString(R.string.verification_use_passphrase) + } else { + null + } bottomSheetVerificationActionItem { id("passphrase") title(stringProvider.getString(R.string.verification_cannot_access_other_session)) titleColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) - subTitle(stringProvider.getString(R.string.verification_use_passphrase)) + subTitle(subtitle) iconRes(R.drawable.ic_arrow_right) iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) listener { listener?.onClickRecoverFromPassphrase() } @@ -122,13 +130,13 @@ class VerificationRequestController @Inject constructor( listener { listener?.onClickOnVerificationStart() } } } - is Loading -> { + is Loading -> { bottomSheetVerificationWaitingItem { id("waiting") title(stringProvider.getString(R.string.verification_request_waiting_for, matrixItem.getBestName())) } } - is Success -> { + is Success -> { if (!pr.invoke().isReady) { if (state.isMe) { bottomSheetVerificationWaitingItem { From d8e9d363fa72733c833afac8b1fb365a411e9366 Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 12 Oct 2020 17:15:38 +0200 Subject: [PATCH 2/3] Cross signing: update CHANGES and clean --- CHANGES.md | 1 + .../crypto/verification/request/VerificationRequestController.kt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 74aaa8cee3..3bda0d9084 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Improvements 🙌: - Implement "Jump to read receipt" and "Mention" actions on the room member profile screen - Add Sygnal API implementation to test is Push are correctly received - Add PushGateway API implementation to test if Push are correctly received + - Cross signing: shouldn't offer to verify with other session when there is not. Bugfix 🐛: - Improve support for image/audio/video/file selection with intent changes (#1376) diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt index 1b2c32a7e4..6e98d924e7 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt @@ -53,7 +53,6 @@ class VerificationRequestController @Inject constructor( if (state.selfVerificationMode) { if (state.hasAnyOtherSession) { - bottomSheetVerificationNoticeItem { id("notice") notice(stringProvider.getString(R.string.verification_open_other_to_verify)) From 5ad46d251daa6b0c8e68802921866295c75a951b Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 12 Oct 2020 17:57:09 +0200 Subject: [PATCH 3/3] Update CHANGES.md Co-authored-by: Benoit Marty --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 3bda0d9084..257837dc6a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,7 +19,7 @@ Improvements 🙌: - Implement "Jump to read receipt" and "Mention" actions on the room member profile screen - Add Sygnal API implementation to test is Push are correctly received - Add PushGateway API implementation to test if Push are correctly received - - Cross signing: shouldn't offer to verify with other session when there is not. + - Cross signing: shouldn't offer to verify with other session when there is not. (#2227) Bugfix 🐛: - Improve support for image/audio/video/file selection with intent changes (#1376)