2021-11-05 13:55:48 +00:00
|
|
|
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,
|
2021-11-24 00:50:15 +00:00
|
|
|
blocked: bool, hasAddedUs: bool, localNickname: string)
|
2021-11-05 13:55:48 +00:00
|
|
|
{.raises: [Exception].} =
|
|
|
|
let payload = %* [{
|
|
|
|
"id": id,
|
|
|
|
"name": ensName,
|
|
|
|
"ensVerified": ensVerified,
|
|
|
|
"alias": alias,
|
|
|
|
"identicon": identicon,
|
|
|
|
"images": {
|
2021-11-24 00:50:15 +00:00
|
|
|
"thumbnail": thumbnail,
|
|
|
|
"large": largeImage
|
2021-11-05 13:55:48 +00:00
|
|
|
},
|
|
|
|
"added": added,
|
|
|
|
"blocked": blocked,
|
|
|
|
"hasAddedUs": hasAddedUs,
|
|
|
|
"localNickname": localNickname
|
|
|
|
}]
|
2021-11-24 00:50:15 +00:00
|
|
|
#TODO figure out why this causes the app to crash and uncomment
|
|
|
|
#discard callPrivateRPC("saveContact".prefix, payload)
|
2021-11-05 13:55:48 +00:00
|
|
|
|
|
|
|
proc sendContactUpdate*(publicKey, ensName, thumbnail: string)
|
|
|
|
{.raises: [Exception].} =
|
|
|
|
let payload = %* [publicKey, ensName, thumbnail]
|
|
|
|
discard callPrivateRPC("sendContactUpdate".prefix, payload)
|