mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-23 12:08:53 +00:00
feat: Add api for getting full pending CR object (#13749)
This commit is contained in:
parent
cdbe3a7718
commit
f934615752
@ -3,6 +3,7 @@ import io_interface
|
|||||||
import ../../../../core/eventemitter
|
import ../../../../core/eventemitter
|
||||||
import ../../../../../app_service/service/contacts/service as contacts_service
|
import ../../../../../app_service/service/contacts/service as contacts_service
|
||||||
import ../../../../../app_service/service/chat/service as chat_service
|
import ../../../../../app_service/service/chat/service as chat_service
|
||||||
|
import ../../../../../app_service/service/message/dto/message as message_dto
|
||||||
|
|
||||||
type
|
type
|
||||||
Controller* = ref object of RootObj
|
Controller* = ref object of RootObj
|
||||||
@ -123,6 +124,9 @@ proc acceptContactRequest*(self: Controller, publicKey: string, contactRequestId
|
|||||||
proc dismissContactRequest*(self: Controller, publicKey: string, contactRequestId: string) =
|
proc dismissContactRequest*(self: Controller, publicKey: string, contactRequestId: string) =
|
||||||
self.contactsService.dismissContactRequest(publicKey, contactRequestId)
|
self.contactsService.dismissContactRequest(publicKey, contactRequestId)
|
||||||
|
|
||||||
|
proc getLatestContactRequestForContact*(self: Controller, publicKey: string): message_dto.MessageDto =
|
||||||
|
self.contactsService.getLatestContactRequestForContact(publicKey)
|
||||||
|
|
||||||
proc switchToOrCreateOneToOneChat*(self: Controller, chatId: string) =
|
proc switchToOrCreateOneToOneChat*(self: Controller, chatId: string) =
|
||||||
self.chatService.switchToOrCreateOneToOneChat(chatId, "")
|
self.chatService.switchToOrCreateOneToOneChat(chatId, "")
|
||||||
|
|
||||||
|
@ -39,6 +39,9 @@ method dismissContactRequest*(self: AccessInterface, publicKey: string, contactR
|
|||||||
method dismissContactRequests*(self: AccessInterface, publicKeysJSON: string) {.base.} =
|
method dismissContactRequests*(self: AccessInterface, publicKeysJSON: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method getLatestContactRequestForContactAsJson*(self: AccessInterface, publicKey: string): string {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method changeContactNickname*(self: AccessInterface, publicKey: string, nickname: string) {.base.} =
|
method changeContactNickname*(self: AccessInterface, publicKey: string, nickname: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
@ -110,6 +110,17 @@ method acceptContactRequest*(self: Module, publicKey: string, contactRequestId:
|
|||||||
method dismissContactRequest*(self: Module, publicKey: string, contactRequestId: string) =
|
method dismissContactRequest*(self: Module, publicKey: string, contactRequestId: string) =
|
||||||
self.controller.dismissContactRequest(publicKey, contactRequestId)
|
self.controller.dismissContactRequest(publicKey, contactRequestId)
|
||||||
|
|
||||||
|
method getLatestContactRequestForContactAsJson*(self: Module, publicKey: string): string =
|
||||||
|
let contactRequest = self.controller.getLatestContactRequestForContact(publicKey)
|
||||||
|
let jsonObj = %* {
|
||||||
|
"id": contactRequest.id,
|
||||||
|
"from": contactRequest.from,
|
||||||
|
"clock": contactRequest.clock,
|
||||||
|
"text": contactRequest.text,
|
||||||
|
"contactRequestState": contactRequest.contactRequestState.int,
|
||||||
|
}
|
||||||
|
return $jsonObj
|
||||||
|
|
||||||
method switchToOrCreateOneToOneChat*(self: Module, publicKey: string) =
|
method switchToOrCreateOneToOneChat*(self: Module, publicKey: string) =
|
||||||
self.controller.switchToOrCreateOneToOneChat(publicKey)
|
self.controller.switchToOrCreateOneToOneChat(publicKey)
|
||||||
|
|
||||||
|
@ -143,6 +143,9 @@ QtObject:
|
|||||||
proc dismissContactRequest*(self: View, publicKey: string, contactRequestId: string) {.slot.} =
|
proc dismissContactRequest*(self: View, publicKey: string, contactRequestId: string) {.slot.} =
|
||||||
self.delegate.dismissContactRequest(publicKey, contactRequestId)
|
self.delegate.dismissContactRequest(publicKey, contactRequestId)
|
||||||
|
|
||||||
|
proc getLatestContactRequestForContactAsJson*(self: View, publicKey: string): string {.slot.} =
|
||||||
|
self.delegate.getLatestContactRequestForContactAsJson(publicKey)
|
||||||
|
|
||||||
proc changeContactNickname*(self: View, publicKey: string, nickname: string) {.slot.} =
|
proc changeContactNickname*(self: View, publicKey: string, nickname: string) {.slot.} =
|
||||||
self.delegate.changeContactNickname(publicKey, nickname)
|
self.delegate.changeContactNickname(publicKey, nickname)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import ../../common/activity_center
|
|||||||
|
|
||||||
import ../settings/service as settings_service
|
import ../settings/service as settings_service
|
||||||
import ../network/service as network_service
|
import ../network/service as network_service
|
||||||
|
import ../message/dto/message as message_dto
|
||||||
import ../visual_identity/service as procs_from_visual_identity_service
|
import ../visual_identity/service as procs_from_visual_identity_service
|
||||||
|
|
||||||
import ./dto/contacts as contacts_dto
|
import ./dto/contacts as contacts_dto
|
||||||
@ -478,7 +479,7 @@ QtObject:
|
|||||||
checkAndEmitACNotificationsFromResponse(self.events, response.result{"activityCenterNotifications"})
|
checkAndEmitACNotificationsFromResponse(self.events, response.result{"activityCenterNotifications"})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "an error occurred while sending contact request", msg = e.msg
|
error "an error occurred while sending the contact request", msg = e.msg
|
||||||
|
|
||||||
proc acceptContactRequest*(self: Service, publicKey: string, contactRequestId: string) =
|
proc acceptContactRequest*(self: Service, publicKey: string, contactRequestId: string) =
|
||||||
try:
|
try:
|
||||||
@ -501,7 +502,7 @@ QtObject:
|
|||||||
checkAndEmitACNotificationsFromResponse(self.events, response.result{"activityCenterNotifications"})
|
checkAndEmitACNotificationsFromResponse(self.events, response.result{"activityCenterNotifications"})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "an error occurred while accepting contact request", msg=e.msg
|
error "an error occurred while accepting the contact request", msg=e.msg
|
||||||
|
|
||||||
proc dismissContactRequest*(self: Service, publicKey: string, contactRequestId: string) =
|
proc dismissContactRequest*(self: Service, publicKey: string, contactRequestId: string) =
|
||||||
try:
|
try:
|
||||||
@ -520,7 +521,25 @@ QtObject:
|
|||||||
checkAndEmitACNotificationsFromResponse(self.events, response.result{"activityCenterNotifications"})
|
checkAndEmitACNotificationsFromResponse(self.events, response.result{"activityCenterNotifications"})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "an error occurred while dismissing contact request", msg=e.msg
|
error "an error occurred while dismissing the contact request", msg=e.msg
|
||||||
|
|
||||||
|
proc getLatestContactRequestForContact*(self: Service, publicKey: string): message_dto.MessageDto =
|
||||||
|
try:
|
||||||
|
let response = status_contacts.getLatestContactRequestForContact(publicKey)
|
||||||
|
|
||||||
|
if not response.error.isNil:
|
||||||
|
error "error getting incoming contact request ", msg = response.error.message
|
||||||
|
return
|
||||||
|
|
||||||
|
let messages = response.result{"messages"}
|
||||||
|
if messages == nil or len(messages) < 1:
|
||||||
|
error "can't find incoming contact request for", publicKey
|
||||||
|
return
|
||||||
|
|
||||||
|
return messages[0].toMessageDto()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
error "an error occurred while getting incoming contact request", msg=e.msg
|
||||||
|
|
||||||
proc changeContactNickname*(self: Service, publicKey: string, nickname: string) =
|
proc changeContactNickname*(self: Service, publicKey: string, nickname: string) =
|
||||||
var contact = self.getContactById(publicKey)
|
var contact = self.getContactById(publicKey)
|
||||||
|
@ -59,6 +59,10 @@ proc declineContactRequest*(id: string): RpcResponse[JsonNode] {.raises: [Except
|
|||||||
}]
|
}]
|
||||||
result = callPrivateRPC("declineContactRequest".prefix, payload)
|
result = callPrivateRPC("declineContactRequest".prefix, payload)
|
||||||
|
|
||||||
|
proc getLatestContactRequestForContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
|
let payload = %* [id]
|
||||||
|
result = callPrivateRPC("getLatestContactRequestForContact".prefix, payload)
|
||||||
|
|
||||||
proc sendContactUpdate*(publicKey, ensName, thumbnail: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
proc sendContactUpdate*(publicKey, ensName, thumbnail: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
let payload = %* [publicKey, ensName, thumbnail]
|
let payload = %* [publicKey, ensName, thumbnail]
|
||||||
result = callPrivateRPC("sendContactUpdate".prefix, payload)
|
result = callPrivateRPC("sendContactUpdate".prefix, payload)
|
||||||
|
@ -91,6 +91,11 @@ QtObject {
|
|||||||
root.contactsModule.dismissContactRequest(pubKey, contactRequestId)
|
root.contactsModule.dismissContactRequest(pubKey, contactRequestId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLatestContactRequestForContactAsJson(pubKey) {
|
||||||
|
let resp = root.contactsModule.getLatestContactRequestForContactAsJson(pubKey)
|
||||||
|
return JSON.parse(resp)
|
||||||
|
}
|
||||||
|
|
||||||
function markAsTrusted(pubKey) {
|
function markAsTrusted(pubKey) {
|
||||||
root.contactsModule.markAsTrusted(pubKey)
|
root.contactsModule.markAsTrusted(pubKey)
|
||||||
}
|
}
|
||||||
|
2
vendor/status-go
vendored
2
vendor/status-go
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 3f98a34eae7275bd5ee055de8e4f32213370cdaa
|
Subproject commit 577db512c6953bec5a82b961cd901c58851362dd
|
Loading…
x
Reference in New Issue
Block a user