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

Warn the user when unverified user has changed their identity #3621

Merged
merged 23 commits into from
Oct 8, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 8, 2024

Content

As per element-hq/element-meta#2544

Using matrix-org/matrix-rust-sdk#4022 and matrix-org/matrix-rust-sdk#4068

Draft since the application is crashing for now when clicking on OK to pin the user. EDIT The crash has been fixed in matrix-org/matrix-rust-sdk#4089 so an SDK release will be neeeded, but this is not blocking this PR anymore (pinning identity cannot be tested, but the PR can be reviewed).

Motivation and context

element-hq/element-meta#2544

Screenshots / GIFs

Tests

  • Alice and Bob in a e2e room
  • Alice has not verified Bob
  • Messages can be sent
  • Bob reset their identity
  • Alice should see the banner, until they click on OK to pin the identity of Bob (but currently this is crashing)

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • 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
  • Pull request includes a sign off
  • You've made a self review of your PR

@bmarty bmarty added the PR-Feature For a new feature label Oct 8, 2024
Copy link
Contributor

github-actions bot commented Oct 8, 2024

📱 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/TgzKg7

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 8, 2024
@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 Oct 8, 2024
@bmarty bmarty force-pushed the feature/bma/composerAlert branch from 9e01997 to 0fd275d Compare October 8, 2024 09:48
@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Oct 8, 2024
@bmarty bmarty marked this pull request as ready for review October 8, 2024 09:50
@bmarty bmarty requested a review from a team as a code owner October 8, 2024 09:50
@bmarty bmarty requested review from jmartinesp and removed request for a team October 8, 2024 09:50
}
is PermalinkData.FallbackLink,
is PermalinkData.RoomEmailInviteLink -> {
context.openUrlInExternalApp(url)
activity.openUrlInChromeCustomTab(null, darkTheme, url)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: at some point, direct usage of openUrlInExternalApp should be forbidden, but this is out of scope of this PR.

@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 Oct 8, 2024
Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of suggestions.

) : Presenter<IdentityChangeState> {
@Composable
override fun present(): IdentityChangeState {
val roomMemberIdentityStateChange = remember {
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this just use produceState?

Copy link
Member

Choose a reason for hiding this comment

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

Yes this would make more sense. Also use by delegate when possible?

modifier: Modifier = Modifier,
) {
// Pick the first identity change to PinViolation
val identityChange = state.roomMemberIdentityStateChanges.firstOrNull {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename it to something like dangerousIdentityChange or pinViolationIdentityChange?


return IdentityChangeState(
roomMemberIdentityStateChanges = roomMemberIdentityStateChange.value
.filter { it.roomMember.userId !in ignoredUserIdChange.value }
Copy link
Member

Choose a reason for hiding this comment

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

I guess the list will never be large, but we are filtering on the main thread for every composition ^

Copy link
Member Author

Choose a reason for hiding this comment

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

This code does not exist anymore, are you reviewing an old version?

)

data class RoomMemberIdentityStateChange(
val roomMember: RoomMember,
Copy link
Member

Choose a reason for hiding this comment

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

Could we create a specific data class instead of passing RoomMember if we only need a few fields?

@bmarty
Copy link
Member Author

bmarty commented Oct 8, 2024

@ganfra @jmartinesp thanks for the fast review. I think I have handled all your remarks.
I took the opportunity to update the code regarding typing notification as it had similar problems.

Copy link

sonarqubecloud bot commented Oct 8, 2024

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 8, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 8, 2024
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 90.73171% with 19 lines in your changes missing coverage. Please review.

Project coverage is 82.70%. Comparing base (409564a) to head (873d807).
Report is 27 commits behind head on develop.

Files with missing lines Patch % Lines
...pl/crypto/identity/IdentityChangeStatePresenter.kt 85.00% 2 Missing and 4 partials ⚠️
...es/impl/crypto/identity/IdentityChangeStateView.kt 87.50% 2 Missing and 2 partials ⚠️
...res/messages/impl/typing/TypingNotificationView.kt 60.00% 2 Missing ⚠️
...ment/android/features/messages/impl/utils/Emoji.kt 0.00% 1 Missing and 1 partial ⚠️
...ent/android/features/messages/impl/MessagesView.kt 83.33% 0 Missing and 1 partial ⚠️
...mpl/crypto/identity/IdentityChangeStateProvider.kt 95.65% 1 Missing ⚠️
...essages/impl/typing/TypingNotificationPresenter.kt 88.88% 0 Missing and 1 partial ⚠️
.../libraries/androidutils/browser/ChromeCustomTab.kt 0.00% 1 Missing ⚠️
...gnsystem/atomic/molecules/ComposerAlertMolecule.kt 97.22% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3621      +/-   ##
===========================================
+ Coverage    82.65%   82.70%   +0.04%     
===========================================
  Files         1735     1744       +9     
  Lines        41187    41334     +147     
  Branches      5000     5016      +16     
===========================================
+ Hits         34043    34185     +142     
+ Misses        5380     5376       -4     
- Partials      1764     1773       +9     

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

@bmarty bmarty enabled auto-merge October 8, 2024 13:34
@bmarty bmarty disabled auto-merge October 8, 2024 14:33
@bmarty bmarty merged commit 0ffd787 into develop Oct 8, 2024
31 of 33 checks passed
@bmarty bmarty deleted the feature/bma/composerAlert branch October 8, 2024 14:33
@bmarty bmarty added Z-NextRelease For issues and PRs which should be included in the NextRelease. and removed X-Release-Blocker labels Oct 8, 2024
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 Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants