mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-08 12:46:08 +00:00
feat(libstatus): introduce API to get contact by ID
This commit is contained in:
parent
d5ba992c81
commit
b8c5059de7
@ -43,3 +43,6 @@ proc removePeer*(peer: string) =
|
|||||||
|
|
||||||
proc markTrustedPeer*(peer: string) =
|
proc markTrustedPeer*(peer: string) =
|
||||||
discard callPrivateRPC("markTrustedPeer".prefix(false), %* [peer])
|
discard callPrivateRPC("markTrustedPeer".prefix(false), %* [peer])
|
||||||
|
|
||||||
|
proc getContactByID*(id: string): string =
|
||||||
|
result = callPrivateRPC("getContactByID".prefix, %* [id])
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
import json
|
||||||
import eventemitter
|
import eventemitter
|
||||||
import libstatus/types
|
import libstatus/types
|
||||||
|
import libstatus/core as libstatus_core
|
||||||
|
|
||||||
type
|
type
|
||||||
MailServer* = ref object
|
MailServer* = ref object
|
||||||
@ -10,7 +12,36 @@ type
|
|||||||
name*, address*: string
|
name*, address*: string
|
||||||
|
|
||||||
type Profile* = ref object
|
type Profile* = ref object
|
||||||
username*, identicon*: string
|
id*, alias*, username*, identicon*: string
|
||||||
|
ensVerified*: bool
|
||||||
|
ensVerifiedAt*: int
|
||||||
|
ensVerificationEntries*: int
|
||||||
|
|
||||||
proc toProfileModel*(account: Account): Profile =
|
proc toProfileModel*(account: Account): Profile =
|
||||||
result = Profile(username: account.name, identicon: account.photoPath)
|
result = Profile(
|
||||||
|
id: "",
|
||||||
|
username: account.name,
|
||||||
|
identicon: account.photoPath,
|
||||||
|
alias: account.name,
|
||||||
|
ensVerified: false,
|
||||||
|
ensVerifiedAt: 0,
|
||||||
|
ensVerificationEntries: 0,
|
||||||
|
)
|
||||||
|
|
||||||
|
proc toProfileModel*(profile: JsonNode): Profile =
|
||||||
|
result = Profile(
|
||||||
|
id: profile["id"].str,
|
||||||
|
username: profile["alias"].str,
|
||||||
|
identicon: profile["identicon"].str,
|
||||||
|
alias: profile["alias"].str,
|
||||||
|
ensVerified: profile["ensVerified"].getBool,
|
||||||
|
ensVerifiedAt: profile["ensVerifiedAt"].getInt,
|
||||||
|
ensVerificationEntries: profile["ensVerificationEntries"].getInt
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
proc getContactByID*(id: string): Profile =
|
||||||
|
let response = libstatus_core.getContactByID(id)
|
||||||
|
let val = parseJSON($response)
|
||||||
|
result = toProfileModel(val)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user