From 9b7f9a086d8537a6ed86d5b71e70bde3f0e71b03 Mon Sep 17 00:00:00 2001 From: Boris Melnik Date: Wed, 19 Jan 2022 12:30:08 +0300 Subject: [PATCH] refactor: Add methods for groups (#129) --- status/statusgo_backend_new/chat.nim | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/status/statusgo_backend_new/chat.nim b/status/statusgo_backend_new/chat.nim index b13c711..3244ad8 100644 --- a/status/statusgo_backend_new/chat.nim +++ b/status/statusgo_backend_new/chat.nim @@ -100,4 +100,32 @@ proc unmuteChat*(chatId: string): RpcResponse[JsonNode] {.raises: [Exception].} proc deleteMessagesByChatId*(chatId: string): RpcResponse[JsonNode] {.raises: [Exception].} = let payload = %* [chatId] - result = callPrivateRPC("deleteMessagesByChatID".prefix, payload) \ No newline at end of file + result = callPrivateRPC("deleteMessagesByChatID".prefix, payload) + +proc addGroupMembers*(chatId: string, pubKeys: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [nil, chatId, pubKeys] + result = callPrivateRPC("addMembersToGroupChat".prefix, payload) + +proc removeMembersFromGroupChat*(chatId: string, pubKey: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [nil, chatId, pubKey] + result = callPrivateRPC("removeMemberFromGroupChat".prefix, payload) + +proc renameGroupChat*(chatId: string, newName: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [nil, chatId, newName] + result = callPrivateRPC("changeGroupChatName".prefix, payload) + +proc makeAdmin*(chatId: string, pubKey: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [nil, chatId, [pubKey]] + result = callPrivateRPC("addAdminsToGroupChat".prefix, payload) + +proc createGroupChat*(groupName: string, pubKeys: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [nil, groupName, pubKeys] + result = callPrivateRPC("createGroupChatWithMembers".prefix, payload) + +proc confirmJoiningGroup*(chatId: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [chatId] + result = callPrivateRPC("confirmJoiningGroup".prefix, payload) + +proc createGroupChatFromInvitation*(groupName: string, chatId: string, adminPK: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [groupName, chatId, adminPK] + result = callPrivateRPC("createGroupChatFromInvitation".prefix, payload) \ No newline at end of file