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

feat(Profile flow) ID verification flows (incoming/outgoing) #13727

Merged
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
198 changes: 169 additions & 29 deletions storybook/pages/ProfileDialogViewPage.qml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ui/app/AppLayouts/Profile/panels/ContactPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ StatusListItem {
width: visible ? implicitWidth : 0
height: visible ? implicitHeight : 0
text: verificationRequestStatus === Constants.verificationStatus.verifying ?
qsTr("Respond to ID Request") :
qsTr("See ID Request")
qsTr("Reply to ID verification request") :
qsTr("Review ID verification reply")
size: StatusBaseButton.Size.Small
onClicked: root.showVerificationRequest(root.publicKey)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ StatusDialog {
title: !d.dbEncryptionInProgress ? qsTr("Re-encryption complete") :
qsTr("Re-encrypting your data with your new password...")
subTitle: !d.dbEncryptionInProgress ? qsTr("Restart Status and log in using your new password") :
qsTr("Do not quit the app of turn off your device")
qsTr("Do not quit the app or turn off your device")
statusListItemSubTitle.customColor: !d.passwordChanged ? Style.current.red : Theme.palette.successColor1
statusListItemIcon.active: d.passwordChanged
asset.name: "checkmark-circle"
Expand Down
2 changes: 1 addition & 1 deletion ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ QtObject {
icon: "profile"})
append({subsection: Constants.settingsSubsection.password,
text: qsTr("Password"),
icon: "profile"})
icon: "password"})
append({subsection: Constants.settingsSubsection.keycard,
text: qsTr("Keycard"),
icon: "keycard"})
Expand Down
5 changes: 2 additions & 3 deletions ui/app/AppLayouts/Profile/views/ContactsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ SettingsContentBase {
store: ({contactsStore: root.contactsStore})

onOpenProfileClicked: function (pubkey) {
Global.openProfilePopup(pubkey, null)
Global.openProfilePopup(pubkey, null, null)
}
onCreateOneToOneChat: function (communityId, chatId, ensName) {
root.contactsStore.joinPrivateChat(chatId)
Expand Down Expand Up @@ -216,7 +216,7 @@ SettingsContentBase {
}

onShowVerificationRequest: {
Global.openIncomingIDRequestPopup(publicKey, null)
Global.openIncomingIDRequestPopup(publicKey, null, null)
}
}

Expand Down Expand Up @@ -320,4 +320,3 @@ SettingsContentBase {
}
}
}

45 changes: 23 additions & 22 deletions ui/app/mainui/Popups.qml
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,13 @@ QtObject {
openPopup(removeIDVerificationPopupComponent, {publicKey, contactDetails}, cb)
}

function openOutgoingIDRequestPopup(publicKey, cb) {
function openOutgoingIDRequestPopup(publicKey, contactDetails, cb) {
let details = contactDetails ?? Utils.getContactDetailsAsJson(publicKey)
try {
const verificationDetails = root.rootStore.profileSectionStore.contactsStore.getSentVerificationDetailsAsJson(publicKey)
const verificationDetails = rootStore.contactStore.getSentVerificationDetailsAsJson(publicKey)
const popupProperties = {
userPublicKey: publicKey,
publicKey: publicKey,
contactDetails: details,
verificationStatus: verificationDetails.requestStatus,
verificationChallenge: verificationDetails.challenge,
verificationResponse: verificationDetails.response,
Expand All @@ -202,13 +204,9 @@ QtObject {
}
}

function openIncomingIDRequestPopup(publicKey, cb) {
const popupProperties = {
contactsStore: root.rootStore.profileSectionStore.contactsStore,
publicKey: publicKey
}

openPopup(contactVerificationRequestPopupComponent, popupProperties, cb)
function openIncomingIDRequestPopup(publicKey, contactDetails, cb) {
let details = contactDetails ?? Utils.getContactDetailsAsJson(publicKey)
openPopup(contactVerificationRequestPopupComponent, {publicKey, contactDetails: details})
}

function openInviteFriendsToCommunityPopup(community, communitySectionModule, cb) {
Expand Down Expand Up @@ -357,7 +355,7 @@ QtObject {
onAccepted: {
rootStore.contactStore.removeContact(publicKey)
if (removeIDVerification)
rootStore.contactStore.cancelVerificationRequest(publicKey)
rootStore.contactStore.removeTrustStatus(publicKey)
if (markAsUntrusted) {
rootStore.contactStore.markUntrustworthy(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 removed from contacts and marked as untrusted").arg(mainDisplayName))
Expand All @@ -372,11 +370,14 @@ QtObject {
Component {
id: contactVerificationRequestPopupComponent
ContactVerificationRequestPopup {
onResponseSent: {
root.rootStore.profileSectionStore.contactsStore.acceptVerificationRequest(senderPublicKey, response)
contactsStore: rootStore.contactStore
onResponseSent: (senderPublicKey, response) => {
contactsStore.acceptVerificationRequest(senderPublicKey, response)
Global.displaySuccessToastMessage(qsTr("ID verification reply sent"))
}
onVerificationRefused: {
root.rootStore.profileSectionStore.contactsStore.declineVerificationRequest(senderPublicKey)
onVerificationRefused: (senderPublicKey) => {
contactsStore.declineVerificationRequest(senderPublicKey)
Global.displaySuccessToastMessage(qsTr("ID verification request declined"))
}
onClosed: destroy()
}
Expand All @@ -386,13 +387,15 @@ QtObject {
id: contactOutgoingVerificationRequestPopupComponent
OutgoingContactVerificationRequestPopup {
onVerificationRequestCanceled: {
root.rootStore.profileSectionStore.contactsStore.cancelVerificationRequest(userPublicKey)
rootStore.contactStore.cancelVerificationRequest(publicKey)
}
onUntrustworthyVerified: {
root.rootStore.profileSectionStore.contactsStore.verifiedUntrustworthy(userPublicKey)
rootStore.contactStore.verifiedUntrustworthy(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 marked as untrusted").arg(mainDisplayName))
}
onTrustedVerified: {
root.rootStore.profileSectionStore.contactsStore.verifiedTrusted(userPublicKey)
rootStore.contactStore.verifiedTrusted(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 ID verified").arg(mainDisplayName))
}
onClosed: destroy()
}
Expand All @@ -411,7 +414,7 @@ QtObject {
id: markAsIDVerifiedPopupComponent
MarkAsIDVerifiedDialog {
onAccepted: {
rootStore.contactStore.verifiedTrusted(publicKey)
rootStore.contactStore.markAsTrusted(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 ID verified").arg(mainDisplayName))
close()
}
Expand Down Expand Up @@ -576,8 +579,6 @@ QtObject {
MarkAsUntrustedPopup {
onAccepted: {
rootStore.contactStore.markUntrustworthy(publicKey)
if (removeIDVerification)
rootStore.contactStore.cancelVerificationRequest(publicKey)
if (removeContact) {
rootStore.contactStore.removeContact(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 removed from contacts and marked as untrusted").arg(mainDisplayName))
Expand Down Expand Up @@ -608,7 +609,7 @@ QtObject {
onAccepted: {
rootStore.contactStore.blockContact(publicKey)
if (removeIDVerification)
rootStore.contactStore.cancelVerificationRequest(publicKey)
rootStore.contactStore.removeTrustStatus(publicKey)
if (removeContact)
rootStore.contactStore.removeContact(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 blocked").arg(mainDisplayName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ StatusFlatButton {

signal activate()

enabled: verificationStatus == Constants.verificationStatus.verifying ||
verificationStatus == Constants.verificationStatus.verified
enabled: verificationStatus === Constants.verificationStatus.verifying ||
verificationStatus === Constants.verificationStatus.verified
size: StatusBaseButton.Size.Small
text: {
switch (verificationStatus) {
Expand Down Expand Up @@ -47,4 +47,4 @@ StatusFlatButton {
}

onClicked: root.activate()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ActivityNotificationMessage {
OutgoingContactVerificationCta {
verificationStatus: notification ? notification.verificationStatus : Constants.verificationStatus.unverified
onActivate: {
Global.openOutgoingIDRequestPopup(root.contactId, popup => {})
Global.openOutgoingIDRequestPopup(root.contactId, root.contactDetails, null)
root.closeActivityCenter()
}
}
Expand All @@ -70,9 +70,9 @@ ActivityNotificationMessage {
IncomingContactVerificationCta {
verificationStatus: notification ? notification.verificationStatus : Constants.verificationStatus.unverified
onActivate: {
Global.openIncomingIDRequestPopup(root.contactId, popup => {})
Global.openIncomingIDRequestPopup(root.contactId, root.contactDetails, null)
root.closeActivityCenter()
}
}
}
}
}
10 changes: 3 additions & 7 deletions ui/imports/shared/popups/BlockContactConfirmationDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ CommonContactDialog {

readonly property var d: QtObject {
id: d
readonly property int outgoingVerificationStatus: contactDetails.verificationStatus
readonly property int incomingVerificationStatus: contactDetails.incomingVerificationStatus
readonly property bool isVerificationRequestReceived: incomingVerificationStatus === Constants.verificationStatus.verifying ||
incomingVerificationStatus === Constants.verificationStatus.verified
readonly property bool isTrusted: outgoingVerificationStatus === Constants.verificationStatus.trusted ||
incomingVerificationStatus === Constants.verificationStatus.trusted
readonly property bool isTrusted: contactDetails.outgoingVerificationStatus === Constants.verificationStatus.trusted ||
contactDetails.incomingVerificationStatus === Constants.verificationStatus.trusted
}

StatusBaseText {
Expand Down Expand Up @@ -58,7 +54,7 @@ CommonContactDialog {

StatusCheckBox {
id: ctrlRemoveIDVerification
visible: contactDetails.isContact && !d.isTrusted && d.isVerificationRequestReceived
visible: (contactDetails.isContact && d.isTrusted) || contactDetails.trustStatus === Constants.trustStatus.trusted
Copy link
Contributor

Choose a reason for hiding this comment

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

imo contactDetails.isContact && d.isTrusted) is sufficient

Copy link
Member Author

@caybro caybro Feb 29, 2024

Choose a reason for hiding this comment

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

Yeah I wanted to make double sure (also for Storybook) :) It can't hurt and also I wasn't certain how this would get implemented in the end when I started working on this

checked: visible
enabled: false
text: qsTr("Remove ID verification")
Expand Down
4 changes: 3 additions & 1 deletion ui/imports/shared/popups/CommonContactDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ StatusDialog {

required property string publicKey
required property var contactDetails
property bool loadingContactDetails

default property alias content: contentLayout.children

Expand All @@ -26,7 +27,7 @@ StatusDialog {
contactDetails.displayName, contactDetails.alias)
readonly property string optionalDisplayName: ProfileUtils.displayName("", contactDetails.name, contactDetails.displayName, contactDetails.alias)

width: 480
width: Math.max(implicitWidth, 480)
horizontalPadding: 0
topPadding: 20
bottomPadding: 0
Expand All @@ -47,6 +48,7 @@ StatusDialog {
imageHeight: 60
ensVerified: contactDetails.ensVerified
onlineStatus: contactDetails.onlineStatus
loading: root.loadingContactDetails
}

ColumnLayout {
Expand Down
Loading