41 lines
1.3 KiB
Nim
41 lines
1.3 KiB
Nim
import json, strmisc
|
|
import core, utils
|
|
import response_type
|
|
|
|
export response_type
|
|
|
|
proc getContacts*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|
let payload = %* []
|
|
result = callPrivateRPC("contacts".prefix, payload)
|
|
|
|
proc getContactById*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|
let payload = %* [id]
|
|
result = callPrivateRPC("getContactByID".prefix, payload)
|
|
|
|
proc saveContact*(id: string, ensVerified: bool, ensName: string, alias: string,
|
|
identicon: string, thumbnail: string, largeImage: string, added: bool,
|
|
blocked: bool, hasAddedUs: bool, localNickname: string)
|
|
{.raises: [Exception].} =
|
|
let payload = %* [{
|
|
"id": id,
|
|
"name": ensName,
|
|
"ensVerified": ensVerified,
|
|
"alias": alias,
|
|
"identicon": identicon,
|
|
"images": {
|
|
"thumbnail": thumbnail,
|
|
"large": largeImage
|
|
},
|
|
"added": added,
|
|
"blocked": blocked,
|
|
"hasAddedUs": hasAddedUs,
|
|
"localNickname": localNickname
|
|
}]
|
|
#TODO figure out why this causes the app to crash and uncomment
|
|
#discard callPrivateRPC("saveContact".prefix, payload)
|
|
|
|
proc sendContactUpdate*(publicKey, ensName, thumbnail: string)
|
|
{.raises: [Exception].} =
|
|
let payload = %* [publicKey, ensName, thumbnail]
|
|
discard callPrivateRPC("sendContactUpdate".prefix, payload)
|