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

feature(crypto): verification violation handling and block sending #4126

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Jan 8, 2025

Draft as it depends on matrix-org/matrix-rust-sdk#4478

Android part of element-hq/element-meta#2492 (still partial as there is no way to verify other users yet on EX, so you can only withdraw the verification requirement).

Content

image

When a previously verified user is not anymore there will now be a banner on top of the composer. The composer will be in a disabled state, as anyhow sending will fail (as per element-hq/element-meta#2488)

Motivation and context

Screenshots / GIFs

Dark:
image
withdraw

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@BillCarsonFr BillCarsonFr added the PR-Feature For a new feature label Jan 8, 2025
@BillCarsonFr BillCarsonFr force-pushed the feature/valere/support_verification_violation_banner branch from 27093ef to 0566d90 Compare January 20, 2025 07:57
Copy link
Contributor

github-actions bot commented Jan 20, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/xWozr2

@BillCarsonFr BillCarsonFr added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jan 20, 2025
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jan 20, 2025
@BillCarsonFr BillCarsonFr force-pushed the feature/valere/support_verification_violation_banner branch from 159fd2a to c012fa1 Compare January 20, 2025 10:39
@BillCarsonFr BillCarsonFr added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jan 20, 2025
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jan 20, 2025
Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 93.69369% with 7 lines in your changes missing coverage. Please review.

Project coverage is 83.37%. Comparing base (3668e86) to head (68a3902).

Files with missing lines Patch % Lines
...pl/crypto/identity/IdentityChangeStatePresenter.kt 72.72% 2 Missing and 1 partial ⚠️
...sages/impl/messagecomposer/MessageComposerUtils.kt 90.00% 0 Missing and 2 partials ⚠️
...ssages/impl/messagecomposer/MessageComposerView.kt 60.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4126      +/-   ##
===========================================
+ Coverage    83.35%   83.37%   +0.01%     
===========================================
  Files         1886     1888       +2     
  Lines        49403    49474      +71     
  Branches      5804     5812       +8     
===========================================
+ Hits         41180    41249      +69     
- Misses        6134     6137       +3     
+ Partials      2089     2088       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BillCarsonFr BillCarsonFr marked this pull request as ready for review January 20, 2025 14:43
@BillCarsonFr BillCarsonFr requested a review from a team as a code owner January 20, 2025 14:43
@BillCarsonFr BillCarsonFr requested review from bmarty and removed request for a team January 20, 2025 14:43
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks! Just need some renaming and cleanup, let me know if I can do anything else.

@@ -32,7 +33,8 @@ fun IdentityChangeStateView(
// Pick the first identity change to PinViolation
val pinViolationIdentityChange = state.roomMemberIdentityStateChanges.firstOrNull {
// For now only render PinViolation
it.identityState == IdentityState.PinViolation
it.identityState == IdentityState.PinViolation ||
it.identityState == IdentityState.VerificationViolation
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the 2 comments above please? Looks like there are not true anymore :)

Also probably pinViolationIdentityChange could be rename to something more generic like firstRoomMemberIdentityStateChange.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -10,5 +10,6 @@ package io.element.android.features.messages.impl.crypto.identity
import io.element.android.libraries.matrix.api.core.UserId

sealed interface IdentityChangeEvent {
data class Submit(val userId: UserId) : IdentityChangeEvent
data class PinViolation(val userId: UserId) : IdentityChangeEvent
Copy link
Member

Choose a reason for hiding this comment

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

Should be renamed to something more related to the action that will be performed. I propose PinUserIdentity.

@@ -10,5 +10,6 @@ package io.element.android.features.messages.impl.crypto.identity
import io.element.android.libraries.matrix.api.core.UserId

sealed interface IdentityChangeEvent {
data class Submit(val userId: UserId) : IdentityChangeEvent
data class PinViolation(val userId: UserId) : IdentityChangeEvent
data class VerificationViolation(val userId: UserId) : IdentityChangeEvent
Copy link
Member

Choose a reason for hiding this comment

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

Should be renamed to something more related to the action that will be performed. I propose WithdrawVerification.

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed

@@ -94,15 +99,22 @@ class IdentityChangeStatePresenter @Inject constructor(
Timber.e(it, "Failed to pin identity for user $userId")
}
}

private fun CoroutineScope.withdrawVerificationRequirement(userId: UserId) = launch {
Copy link
Member

Choose a reason for hiding this comment

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

Rename to withdrawVerification?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -66,6 +66,7 @@ interface EncryptionService {
* Remember this identity, ensuring it does not result in a pin violation.
*/
suspend fun pinUserIdentity(userId: UserId): Result<Unit>
suspend fun withdrawVerificationRequirement(userId: UserId): Result<Unit>
Copy link
Member

Choose a reason for hiding this comment

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

Rename to withdrawVerification?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

import io.element.android.libraries.textcomposer.R

@Composable
internal fun DisabledComposerView(
Copy link
Member

Choose a reason for hiding this comment

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

I understand the aim of this Composable, but, as @jmartinesp mentionned, we take the risk that if a change in the real composer UI is done, this component is not updated.

I have seen that you have added screenshot test in the same view than the real composer, so this may mitigate this risk, thanks.

So it's OK for me!

Copy link
Member Author

Choose a reason for hiding this comment

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

ok. not ideal but enough for now. We need anyhow a way to have the composer disabled, and properly support transition to disabled in the middle of editing/recording ..

@@ -705,4 +723,33 @@ class MessageComposerPresenter @AssistedInject constructor(
}
}
}

@OptIn(ExperimentalCoroutinesApi::class)
private fun ProduceStateScope<PersistentList<RoomMemberIdentityStateChange>>.observeRoomMemberIdentityStateChange() {
Copy link
Member

Choose a reason for hiding this comment

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

This method already exists in IdentityChangeStatePresenter, we should avoid copy pasting full block of code like this. Can you extract it please?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to a Utils class

@@ -78,7 +78,11 @@ fun ComposerAlertMolecule(
text = content,
modifier = Modifier.weight(1f),
style = ElementTheme.typography.fontBodyMdRegular,
color = ElementTheme.colors.textPrimary,
color = if (isCritical) {
ElementTheme.colors.textCriticalPrimary
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 a bit "red on red" in dark theme, is it the expected design?

image

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no dark version in figma. I am color blind so not sure if it's strange or not ^^

Copy link
Member

Choose a reason for hiding this comment

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

The composer box does not have the same width:

image

I guess a user with hardly notices that, but maybe improve it?

Copy link
Member Author

Choose a reason for hiding this comment

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

a bit better, but the paddings/margins are a bit strange on the composer de44045

@BillCarsonFr BillCarsonFr added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jan 24, 2025
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Feature For a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants