Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display specific message when verif code malformed #6395

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6395.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display specific message when verification QR code is malformed
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal class DefaultQrCodeVerificationTransaction(
// Perform some checks
if (otherQrCodeData.transactionId != transactionId) {
Timber.d("## Verification QR: Invalid transaction actual ${otherQrCodeData.transactionId} expected:$transactionId")
cancel(CancelCode.QrCodeInvalid)
cancel(CancelCode.UnknownTransaction)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that UnknownTransaction was never used.

That said, it looks that this change is not triggering the usage of ConclusionState.INVALID_QR_CODE.

I would have split the 2 changes into 2 distinct commits, or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I lowered the warning level when the QR code is malformed. But in this case the QR code is valid but it's not the right transaction Id, so it looks like it's more worrying than just a format error, so I still want it to have the old warning, it would appear has a compromised modal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand the same thing. 2 commits would have been better :).

Also this case can happen if I scan any other unrelated but well formatted verification QR code, so maybe in this case, this is probably not really a compromission, so we may just show something like "this is not the expected QR code" and cancel the verification. Not sure if we want to bother more about that.

return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ class VerificationConclusionController @Inject constructor(

bottomGotIt()
}
ConclusionState.INVALID_QR_CODE -> {
bottomSheetVerificationNoticeItem {
id("invalid_qr")
notice(host.stringProvider.getString(R.string.verify_invalid_qr_notice).toEpoxyCharSequence())
}

bottomGotIt()
}
ConclusionState.CANCELLED -> {
bottomSheetVerificationNoticeItem {
id("notice_cancelled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ data class VerificationConclusionViewState(
enum class ConclusionState {
SUCCESS,
WARNING,
CANCELLED
CANCELLED,
INVALID_QR_CODE
}

class VerificationConclusionViewModel(initialState: VerificationConclusionViewState) :
Expand All @@ -44,7 +45,9 @@ class VerificationConclusionViewModel(initialState: VerificationConclusionViewSt
val args = viewModelContext.args<VerificationConclusionFragment.Args>()

return when (safeValueOf(args.cancelReason)) {
CancelCode.QrCodeInvalid,
CancelCode.QrCodeInvalid -> {
VerificationConclusionViewState(ConclusionState.INVALID_QR_CODE, args.isMe)
}
CancelCode.MismatchedUser,
CancelCode.MismatchedSas,
CancelCode.MismatchedCommitment,
Expand Down
1 change: 1 addition & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,7 @@
</string>

<string name="verify_cancelled_notice">Verification has been cancelled. You can start verification again.</string>
<string name="verify_invalid_qr_notice">This QR code looks malformed. Please try to verify with another method.</string>
<string name="verification_cancelled">Verification Cancelled</string>

<string name="recovery_passphrase">Recovery Passphrase</string>
Expand Down