feat: add `markAsTrusted` endpoint (#13751)

Close #13716
This commit is contained in:
Mikhail Rogachev 2024-02-28 16:50:40 +03:00 committed by GitHub
parent eb50a424e4
commit 6ac2f92200
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 33 additions and 0 deletions

View File

@ -126,6 +126,9 @@ proc dismissContactRequest*(self: Controller, publicKey: string, contactRequestI
proc switchToOrCreateOneToOneChat*(self: Controller, chatId: string) = proc switchToOrCreateOneToOneChat*(self: Controller, chatId: string) =
self.chatService.switchToOrCreateOneToOneChat(chatId, "") self.chatService.switchToOrCreateOneToOneChat(chatId, "")
proc markAsTrusted*(self: Controller, publicKey: string) =
self.contactsService.markAsTrusted(publicKey)
proc markUntrustworthy*(self: Controller, publicKey: string) = proc markUntrustworthy*(self: Controller, publicKey: string) =
self.contactsService.markUntrustworthy(publicKey) self.contactsService.markUntrustworthy(publicKey)

View File

@ -77,6 +77,9 @@ method contactUpdated*(self: AccessInterface, publicKey: string) {.base.} =
method contactsStatusUpdated*(self: AccessInterface, statusUpdates: seq[StatusUpdateDto]) {.base.} = method contactsStatusUpdated*(self: AccessInterface, statusUpdates: seq[StatusUpdateDto]) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method markAsTrusted*(self: AccessInterface, publicKey: string): void {.base.} =
raise newException(ValueError, "No implementation available")
method markUntrustworthy*(self: AccessInterface, publicKey: string): void {.base.} = method markUntrustworthy*(self: AccessInterface, publicKey: string): void {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -196,6 +196,9 @@ method contactTrustStatusChanged*(self: Module, publicKey: string, isUntrustwort
self.view.myMutualContactsModel().updateTrustStatus(publicKey, isUntrustworthy) self.view.myMutualContactsModel().updateTrustStatus(publicKey, isUntrustworthy)
self.view.blockedContactsModel().updateTrustStatus(publicKey, isUntrustworthy) self.view.blockedContactsModel().updateTrustStatus(publicKey, isUntrustworthy)
method markAsTrusted*(self: Module, publicKey: string): void =
self.controller.markAsTrusted(publicKey)
method markUntrustworthy*(self: Module, publicKey: string): void = method markUntrustworthy*(self: Module, publicKey: string): void =
self.controller.markUntrustworthy(publicKey) self.controller.markUntrustworthy(publicKey)

View File

@ -155,6 +155,9 @@ QtObject:
proc removeContact*(self: View, publicKey: string) {.slot.} = proc removeContact*(self: View, publicKey: string) {.slot.} =
self.delegate.removeContact(publicKey) self.delegate.removeContact(publicKey)
proc markAsTrusted*(self: View, publicKey: string) {.slot.} =
self.delegate.markAsTrusted(publicKey)
proc markUntrustworthy*(self: View, publicKey: string) {.slot.} = proc markUntrustworthy*(self: View, publicKey: string) {.slot.} =
self.delegate.markUntrustworthy(publicKey) self.delegate.markUntrustworthy(publicKey)

View File

@ -601,6 +601,19 @@ QtObject:
let data = ContactsStatusUpdatedArgs(statusUpdates: @[currentUserStatusUpdate]) let data = ContactsStatusUpdatedArgs(statusUpdates: @[currentUserStatusUpdate])
self.events.emit(SIGNAL_CONTACTS_STATUS_UPDATED, data) self.events.emit(SIGNAL_CONTACTS_STATUS_UPDATED, data)
proc markAsTrusted*(self: Service, publicKey: string) =
let response = status_contacts.markAsTrusted(publicKey)
if not response.error.isNil:
error "error marking as trusted ", msg = response.error.message
return
if self.contacts.hasKey(publicKey):
self.contacts[publicKey].dto.trustStatus = TrustStatus.Trusted
self.events.emit(SIGNAL_CONTACT_TRUSTED,
TrustArgs(publicKey: publicKey, isUntrustworthy: false))
proc markUntrustworthy*(self: Service, publicKey: string) = proc markUntrustworthy*(self: Service, publicKey: string) =
let response = status_contacts.markUntrustworthy(publicKey) let response = status_contacts.markUntrustworthy(publicKey)
if not response.error.isNil: if not response.error.isNil:

View File

@ -67,6 +67,10 @@ proc getImageServerURL*(): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [] let payload = %* []
result = callPrivateRPC("imageServerURL".prefix, payload) result = callPrivateRPC("imageServerURL".prefix, payload)
proc markAsTrusted*(pubkey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [pubkey]
result = callPrivateRPC("markAsTrusted".prefix, payload)
proc markUntrustworthy*(pubkey: string): RpcResponse[JsonNode] {.raises: [Exception].} = proc markUntrustworthy*(pubkey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [pubkey] let payload = %* [pubkey]
result = callPrivateRPC("markAsUntrustworthy".prefix, payload) result = callPrivateRPC("markAsUntrustworthy".prefix, payload)

View File

@ -91,6 +91,10 @@ QtObject {
root.contactsModule.dismissContactRequest(pubKey, contactRequestId) root.contactsModule.dismissContactRequest(pubKey, contactRequestId)
} }
function markAsTrusted(pubKey) {
root.contactsModule.markAsTrusted(pubKey)
}
function markUntrustworthy(pubKey) { function markUntrustworthy(pubKey) {
root.contactsModule.markUntrustworthy(pubKey) root.contactsModule.markUntrustworthy(pubKey)
} }