fix(Profile flow): ID verification cannot be removed (#14308)

fix(UserListPanel): hide the verification icon for yourself

fixes #13619

* split function for reseting trust status and verification+trust status

* rename function to removeTrustVerificationStatus
This commit is contained in:
Andrey Bocharnikov 2024-04-18 23:09:27 +07:00 committed by GitHub
parent 173a02f1fc
commit b5dbac2e74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 63 additions and 17 deletions

View File

@ -75,6 +75,7 @@ method contactsStatusUpdated*(self: Module, statusUpdates: seq[StatusUpdateDto])
method contactUpdated*(self: Module, publicKey: string) = method contactUpdated*(self: Module, publicKey: string) =
let contactDetails = self.controller.getContactDetails(publicKey) let contactDetails = self.controller.getContactDetails(publicKey)
let isMe = publicKey == singletonInstance.userProfile.getPubKey()
self.view.model().updateItem( self.view.model().updateItem(
pubKey = publicKey, pubKey = publicKey,
displayName = contactDetails.dto.displayName, displayName = contactDetails.dto.displayName,
@ -84,7 +85,7 @@ method contactUpdated*(self: Module, publicKey: string) =
alias = contactDetails.dto.alias, alias = contactDetails.dto.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
isContact = contactDetails.dto.isContact, isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(), isVerified = not isMe and contactDetails.dto.isContactVerified(),
isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy, isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy,
) )
@ -129,7 +130,7 @@ proc addChatMember(self: Module, member: ChatMember) =
colorHash = contactDetails.colorHash, colorHash = contactDetails.colorHash,
onlineStatus = status, onlineStatus = status,
isContact = contactDetails.dto.isContact, isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(), isVerified = not isMe and contactDetails.dto.isContactVerified(),
memberRole = member.role, memberRole = member.role,
joined = member.joined, joined = member.joined,
isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy, isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy,
@ -156,6 +157,7 @@ method onMembersChanged*(self: Module, members: seq[ChatMember]) =
method onChatMemberUpdated*(self: Module, publicKey: string, memberRole: MemberRole, joined: bool) = method onChatMemberUpdated*(self: Module, publicKey: string, memberRole: MemberRole, joined: bool) =
let contactDetails = self.controller.getContactDetails(publicKey) let contactDetails = self.controller.getContactDetails(publicKey)
let isMe = publicKey == singletonInstance.userProfile.getPubKey()
self.view.model().updateItem( self.view.model().updateItem(
pubKey = publicKey, pubKey = publicKey,
displayName = contactDetails.dto.displayName, displayName = contactDetails.dto.displayName,
@ -165,7 +167,7 @@ method onChatMemberUpdated*(self: Module, publicKey: string, memberRole: MemberR
alias = contactDetails.dto.alias, alias = contactDetails.dto.alias,
icon = contactDetails.icon, icon = contactDetails.icon,
isContact = contactDetails.dto.isContact, isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(), isVerified = not isMe and contactDetails.dto.isContactVerified(),
memberRole = memberRole, memberRole = memberRole,
joined = joined, joined = joined,
isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy, isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy,

View File

@ -168,6 +168,9 @@ proc sendVerificationRequest*(self: Controller, publicKey: string, challenge: st
proc cancelVerificationRequest*(self: Controller, publicKey: string) = proc cancelVerificationRequest*(self: Controller, publicKey: string) =
self.contactsService.cancelVerificationRequest(publicKey) self.contactsService.cancelVerificationRequest(publicKey)
proc removeTrustVerificationStatus*(self: Controller, publicKey: string) =
self.contactsService.removeTrustVerificationStatus(publicKey)
proc verifiedTrusted*(self: Controller, publicKey: string) = proc verifiedTrusted*(self: Controller, publicKey: string) =
self.contactsService.verifiedTrusted(publicKey) self.contactsService.verifiedTrusted(publicKey)

View File

@ -91,6 +91,9 @@ method markUntrustworthy*(self: AccessInterface, publicKey: string): void {.base
method removeTrustStatus*(self: AccessInterface, publicKey: string): void {.base.} = method removeTrustStatus*(self: AccessInterface, publicKey: string): void {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method removeTrustVerificationStatus*(self: AccessInterface, publicKey: string): void {.base.} =
raise newException(ValueError, "No implementation available")
method getSentVerificationDetailsAsJson*(self: AccessInterface, publicKey: string): string {.base.} = method getSentVerificationDetailsAsJson*(self: AccessInterface, publicKey: string): string {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -245,6 +245,9 @@ method markUntrustworthy*(self: Module, publicKey: string): void =
method removeTrustStatus*(self: Module, publicKey: string): void = method removeTrustStatus*(self: Module, publicKey: string): void =
self.controller.removeTrustStatus(publicKey) self.controller.removeTrustStatus(publicKey)
method removeTrustVerificationStatus*(self: Module, publicKey: string): void =
self.controller.removeTrustVerificationStatus(publicKey)
method getSentVerificationDetailsAsJson*(self: Module, publicKey: string): string = method getSentVerificationDetailsAsJson*(self: Module, publicKey: string): string =
let verificationRequest = self.controller.getVerificationRequestSentTo(publicKey) let verificationRequest = self.controller.getVerificationRequestSentTo(publicKey)
let (name, image, largeImage) = self.controller.getContactNameAndImage(publicKey) let (name, image, largeImage) = self.controller.getContactNameAndImage(publicKey)

View File

@ -202,6 +202,9 @@ QtObject:
proc removeTrustStatus*(self: View, publicKey: string) {.slot.} = proc removeTrustStatus*(self: View, publicKey: string) {.slot.} =
self.delegate.removeTrustStatus(publicKey) self.delegate.removeTrustStatus(publicKey)
proc removeTrustVerificationStatus*(self: View, publicKey: string) {.slot.} =
self.delegate.removeTrustVerificationStatus(publicKey)
proc getSentVerificationDetailsAsJson(self: View, publicKey: string): string {.slot.} = proc getSentVerificationDetailsAsJson(self: View, publicKey: string): string {.slot.} =
return self.delegate.getSentVerificationDetailsAsJson(publicKey) return self.delegate.getSentVerificationDetailsAsJson(publicKey)

View File

@ -714,18 +714,30 @@ QtObject:
error "error verified untrustworthy request", msg=e.msg error "error verified untrustworthy request", msg=e.msg
proc removeTrustStatus*(self: Service, publicKey: string) = proc removeTrustStatus*(self: Service, publicKey: string) =
let response = status_contacts.removeTrustStatus(publicKey) try:
if not response.error.isNil: let response = status_contacts.removeTrustStatus(publicKey)
error "error removing trust status", msg = response.error.message if not response.error.isNil:
return error "error removing trust status", msg = response.error.message
return
if self.contacts.hasKey(publicKey): self.parseContactsResponse(response)
self.contacts[publicKey].dto.trustStatus = TrustStatus.Unknown self.parseContactsResponse(response)
if self.contacts[publicKey].dto.verificationStatus == VerificationStatus.Verified: self.events.emit(SIGNAL_REMOVED_TRUST_STATUS, TrustArgs(publicKey: publicKey, isUntrustworthy: false))
self.contacts[publicKey].dto.verificationStatus = VerificationStatus.Unverified except Exception as e:
error "error in removeTrustStatus request", msg = e.msg
self.events.emit(SIGNAL_REMOVED_TRUST_STATUS, proc removeTrustVerificationStatus*(self: Service, publicKey: string) =
TrustArgs(publicKey: publicKey, isUntrustworthy: false)) try:
let response = status_contacts.removeTrustVerificationStatus(publicKey)
if not response.error.isNil:
error "error removing trust status", msg = response.error.message
return
self.parseContactsResponse(response)
self.events.emit(SIGNAL_REMOVED_TRUST_STATUS, TrustArgs(publicKey: publicKey, isUntrustworthy: false))
self.events.emit(SIGNAL_CONTACT_VERIFIED, ContactArgs(contactId: publicKey))
except Exception as e:
error "error removeTrustVerificationStatus request", msg = e.msg
proc getVerificationRequestSentTo*(self: Service, publicKey: string): VerificationRequest = proc getVerificationRequestSentTo*(self: Service, publicKey: string): VerificationRequest =
try: try:

View File

@ -95,6 +95,10 @@ proc removeTrustStatus*(pubkey: string): RpcResponse[JsonNode] =
let payload = %* [pubkey] let payload = %* [pubkey]
result = callPrivateRPC("removeTrustStatus".prefix, payload) result = callPrivateRPC("removeTrustStatus".prefix, payload)
proc removeTrustVerificationStatus*(pubkey: string): RpcResponse[JsonNode] =
let payload = %* [pubkey]
result = callPrivateRPC("removeTrustVerificationStatus".prefix, payload)
proc getTrustStatus*(pubkey: string): RpcResponse[JsonNode] = proc getTrustStatus*(pubkey: string): RpcResponse[JsonNode] =
let payload = %* [pubkey] let payload = %* [pubkey]
result = callPrivateRPC("getTrustStatus".prefix, payload) result = callPrivateRPC("getTrustStatus".prefix, payload)

View File

@ -264,6 +264,13 @@ SplitView {
ctrlIncomingVerificationStatus.currentIndex = ctrlIncomingVerificationStatus.indexOfValue(Constants.verificationStatus.unverified) ctrlIncomingVerificationStatus.currentIndex = ctrlIncomingVerificationStatus.indexOfValue(Constants.verificationStatus.unverified)
} }
function removeTrustVerificationStatus(publicKey) {
logs.logEvent("rootStore::contactStore::removeTrustVerificationStatus", ["publicKey"], arguments)
ctrlTrustStatus.currentIndex = ctrlTrustStatus.indexOfValue(Constants.trustStatus.unknown)
ctrlVerificationStatus.currentIndex = ctrlVerificationStatus.indexOfValue(Constants.verificationStatus.unverified)
ctrlIncomingVerificationStatus.currentIndex = ctrlIncomingVerificationStatus.indexOfValue(Constants.verificationStatus.unverified)
}
function cancelVerificationRequest(pubKey) { function cancelVerificationRequest(pubKey) {
logs.logEvent("rootStore::contactStore::cancelVerificationRequest", ["pubKey"], arguments) logs.logEvent("rootStore::contactStore::cancelVerificationRequest", ["pubKey"], arguments)
ctrlVerificationStatus.currentIndex = ctrlVerificationStatus.indexOfValue(Constants.verificationStatus.unverified) ctrlVerificationStatus.currentIndex = ctrlVerificationStatus.indexOfValue(Constants.verificationStatus.unverified)
@ -400,6 +407,11 @@ SplitView {
ctrlTrustStatus.currentIndex = ctrlTrustStatus.indexOfValue(Constants.trustStatus.unknown) ctrlTrustStatus.currentIndex = ctrlTrustStatus.indexOfValue(Constants.trustStatus.unknown)
} }
function removeTrustVerificationStatus(publicKey) {
logs.logEvent("contactsStore::removeTrustVerificationStatus", ["publicKey"], arguments)
ctrlTrustStatus.currentIndex = ctrlTrustStatus.indexOfValue(Constants.trustStatus.unknown)
}
function verifiedUntrustworthy(publicKey) { function verifiedUntrustworthy(publicKey) {
logs.logEvent("contactsStore::verifiedUntrustworthy", ["publicKey"], arguments) logs.logEvent("contactsStore::verifiedUntrustworthy", ["publicKey"], arguments)
} }

View File

@ -127,6 +127,10 @@ QtObject {
root.contactsModule.removeTrustStatus(pubKey) root.contactsModule.removeTrustStatus(pubKey)
} }
function removeTrustVerificationStatus(pubKey) {
root.contactsModule.removeTrustVerificationStatus(pubKey)
}
function sendVerificationRequest(pubKey, challenge) { function sendVerificationRequest(pubKey, challenge) {
root.contactsModule.sendVerificationRequest(pubKey, challenge); root.contactsModule.sendVerificationRequest(pubKey, challenge);
Global.displaySuccessToastMessage(qsTr("ID verification request sent")) Global.displaySuccessToastMessage(qsTr("ID verification request sent"))

View File

@ -386,7 +386,7 @@ QtObject {
onAccepted: { onAccepted: {
rootStore.contactStore.removeContact(publicKey) rootStore.contactStore.removeContact(publicKey)
if (removeIDVerification) if (removeIDVerification)
rootStore.contactStore.removeTrustStatus(publicKey) rootStore.contactStore.removeTrustVerificationStatus(publicKey)
if (markAsUntrusted) { if (markAsUntrusted) {
rootStore.contactStore.markUntrustworthy(publicKey) rootStore.contactStore.markUntrustworthy(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 removed from contacts and marked as untrusted").arg(mainDisplayName)) Global.displaySuccessToastMessage(qsTr("%1 removed from contacts and marked as untrusted").arg(mainDisplayName))
@ -457,7 +457,7 @@ QtObject {
id: removeIDVerificationPopupComponent id: removeIDVerificationPopupComponent
RemoveIDVerificationDialog { RemoveIDVerificationDialog {
onAccepted: { onAccepted: {
rootStore.contactStore.removeTrustStatus(publicKey) rootStore.contactStore.removeTrustVerificationStatus(publicKey)
if (markAsUntrusted && removeContact) { if (markAsUntrusted && removeContact) {
rootStore.contactStore.markUntrustworthy(publicKey) rootStore.contactStore.markUntrustworthy(publicKey)
@ -671,7 +671,7 @@ QtObject {
onAccepted: { onAccepted: {
rootStore.contactStore.blockContact(publicKey) rootStore.contactStore.blockContact(publicKey)
if (removeIDVerification) if (removeIDVerification)
rootStore.contactStore.removeTrustStatus(publicKey) rootStore.contactStore.removeTrustVerificationStatus(publicKey)
if (removeContact) if (removeContact)
rootStore.contactStore.removeContact(publicKey) rootStore.contactStore.removeContact(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 blocked").arg(mainDisplayName)) Global.displaySuccessToastMessage(qsTr("%1 blocked").arg(mainDisplayName))

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 12deb2336028639ff11b6a3e08043e2961bed5c4 Subproject commit 78db9054fc4fac565f5fb6cdd711d22e5870d0a1