From 4a5094644f7c13d5877c0d7a6996d51fe18bb5d6 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Wed, 29 Sep 2021 00:10:22 +0300 Subject: [PATCH] feat: sending audio messages (#55) Co-authored-by: Andrei Smirnov --- status/chat.nim | 4 ++++ status/statusgo_backend/chat.nim | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/status/chat.nim b/status/chat.nim index a0e8f8b..e73b3f8 100644 --- a/status/chat.nim +++ b/status/chat.nim @@ -350,6 +350,10 @@ proc editMessage*(self: ChatModel, messageId: string, msg: string) = var response = status_chat.editMessage(messageId, msg) discard self.processMessageUpdateAfterSend(response) +proc sendAudio*(self: ChatModel, chatId: string, audioBase64: string, durationMs: uint64) = + var response = status_chat.sendAudioMessage(chatId, audioBase64, durationMs) + discard self.processMessageUpdateAfterSend(response) + proc sendImage*(self: ChatModel, chatId: string, image: string) = var response = status_chat.sendImageMessage(chatId, image) discard self.processMessageUpdateAfterSend(response) diff --git a/status/statusgo_backend/chat.nim b/status/statusgo_backend/chat.nim index c339585..35ebb6d 100644 --- a/status/statusgo_backend/chat.nim +++ b/status/statusgo_backend/chat.nim @@ -127,6 +127,19 @@ proc sendChatMessage*(chatId: string, msg: string, replyTo: string, contentType: } ]) +proc sendAudioMessage*(chatId: string, audioBase64: string, durationMs: uint64): string = + let preferredUsername = getSetting[string](Setting.PreferredUsername, "") + callPrivateRPC("sendChatMessage".prefix, %* [ + { + "chatId": chatId, + "contentType": ContentType.Audio.int, + "base64Audio": audioBase64, + "audioDurationMs": durationMs, + "ensName": preferredUsername, + "text": "Update to latest version to hear this audio!" + } + ]) + proc sendImageMessage*(chatId: string, image: string): string = let preferredUsername = getSetting[string](Setting.PreferredUsername, "") callPrivateRPC("sendChatMessage".prefix, %* [