refactor(chat): add function to send messages (#141)

This commit is contained in:
Jonathan Rainville 2021-12-22 09:24:14 -05:00 committed by saledjenic
parent fbd06ca881
commit 623d3b0def
2 changed files with 26 additions and 2 deletions

View File

@ -52,6 +52,31 @@ proc deactivateChat*(chatId: string): RpcResponse[JsonNode] {.raises: [Exception
proc clearChatHistory*(chatId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
callPrivateRPC("deleteMessagesByChatID".prefix, %* [chatId])
proc sendChatMessage*(
chatId: string,
msg: string,
replyTo: string,
contentType: int,
preferredUsername: string = "",
communityId: string = "",
stickerHash: string = "",
stickerPack: int = 0,
): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("sendChatMessage".prefix, %* [
{
"chatId": chatId,
"text": msg,
"responseTo": replyTo,
"ensName": preferredUsername,
"sticker": {
"hash": stickerHash,
"pack": stickerPack
},
"contentType": contentType,
"communityId": communityId
}
])
proc sendImages*(chatId: string, images: var seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
let imagesJson = %* images.map(image => %*
{

View File

@ -1,6 +1,5 @@
import json
import ../statusgo_backend_new/eth as eth
import ./eth
# Retrieves number of sticker packs owned by user
# See https://notes.status.im/Q-sQmQbpTOOWCQcYiXtf5g#Read-Sticker-Packs-owned-by-a-user