move chat sending json-rpc into status chat module

This commit is contained in:
Iuri Matias 2020-05-13 15:21:11 -04:00
parent a9e84c685d
commit 9e24821c33
2 changed files with 20 additions and 16 deletions

View File

@ -6,6 +6,7 @@ import state
import status/utils
import status/core as status
import status/chat as status_chat
import status/test as status_test
proc mainProc() =
@ -32,22 +33,7 @@ proc mainProc() =
# result.accountResult = status.queryAccounts()
var sendMessage = proc (msg: string): string =
let payload = %* {
"jsonrpc": "2.0",
"id": 40,
"method": "sendChatMessage".prefix,
"params": [
{
"chatId": "test",
"text": msg,
"responseTo": nil,
"ensName": nil,
"sticker": nil,
"contentType": 1
}
]
}
status.callPrivateRPC($payload)
status_chat.sendPublicChatMessage("test", msg)
let logic = newApplicationView(app, sendMessage)
defer: logic.delete

View File

@ -58,3 +58,21 @@ proc chatMessages*(chatId: string) =
}
discard $libstatus.callPrivateRPC($payload)
# TODO: create template for error handling
proc sendPublicChatMessage*(chatId: string, msg: string): string =
let payload = %* {
"jsonrpc": "2.0",
"id": 40,
"method": "sendChatMessage".prefix,
"params": [
{
"chatId": chatId,
"text": msg,
"responseTo": nil,
"ensName": nil,
"sticker": nil,
"contentType": 1
}
]
}
$libstatus.callPrivateRPC($payload)