From 9e24821c3302b5ae4e5fae73c44f591fc8aff0a6 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 13 May 2020 15:21:11 -0400 Subject: [PATCH] move chat sending json-rpc into status chat module --- src/nim_status_client.nim | 18 ++---------------- src/status/chat.nim | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/nim_status_client.nim b/src/nim_status_client.nim index b890a5a0b0..9aedfe1526 100644 --- a/src/nim_status_client.nim +++ b/src/nim_status_client.nim @@ -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 diff --git a/src/status/chat.nim b/src/status/chat.nim index 9ae670f7e7..ba038058ae 100644 --- a/src/status/chat.nim +++ b/src/status/chat.nim @@ -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)