From eb9c629bbfef3eb7485b59dc49f45b48452235de Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Tue, 18 Jun 2024 11:08:30 +0100 Subject: [PATCH] fix: removeTrustStatus response processing (#15206) --- src/app_service/service/contacts/service.nim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index 37dcff1fc0..127cb60047 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -474,9 +474,11 @@ QtObject: self.events.emit(signal, ContactArgs(contactId: publicKey)) proc parseContactsResponse*(self: Service, response: RpcResponse[JsonNode]) = - if response.result["contacts"] != nil: - for contactJson in response.result["contacts"]: - self.updateContact(contactJson.toContactsDto()) + let contacts = response.result{"contacts"} + if contacts == nil: + return + for contactJson in contacts: + self.updateContact(contactJson.toContactsDto()) proc sendContactRequest*(self: Service, publicKey: string, message: string) = # Prefetch contact to avoid race condition with AC notification @@ -720,7 +722,10 @@ QtObject: return self.parseContactsResponse(response) - self.parseContactsResponse(response) + + if self.contacts.hasKey(publicKey): + self.contacts[publicKey].dto.trustStatus = TrustStatus.Unknown + self.events.emit(SIGNAL_REMOVED_TRUST_STATUS, TrustArgs(publicKey: publicKey, isUntrustworthy: false)) except Exception as e: error "error in removeTrustStatus request", msg = e.msg @@ -964,4 +969,4 @@ QtObject: data.profileShowcase.accounts = map(rpcResponseObj{"response"}.getElems(), proc(x: JsonNode): ProfileShowcaseAccount = toProfileShowcaseAccount(x)) except Exception as e: error "onProfileShowcaseAccountsByAddressFetched", msg = e.msg - self.events.emit(SIGNAL_CONTACT_SHOWCASE_ACCOUNTS_BY_ADDRESS_FETCHED, data) \ No newline at end of file + self.events.emit(SIGNAL_CONTACT_SHOWCASE_ACCOUNTS_BY_ADDRESS_FETCHED, data)