diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index bae6d4cefa..9018805c1d 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -114,10 +114,10 @@ proc asyncCheckPermissionsToJoin*(self: Controller) = self.communityService.asyncCheckPermissionsToJoin(self.getMySectionId()) proc asyncCheckAllChannelsPermissions*(self: Controller) = - self.communityService.asyncCheckAllChannelsPermissions(self.getMySectionId()) + self.chatService.asyncCheckAllChannelsPermissions(self.getMySectionId()) proc asyncCheckChannelPermissions*(self: Controller, communityId: string, chatId: string) = - self.communityService.asyncCheckChannelPermissions(communityId, chatId) + self.chatService.asyncCheckChannelPermissions(communityId, chatId) proc asyncCheckPermissions*(self: Controller) = self.asyncCheckPermissionsToJoin() @@ -699,4 +699,3 @@ proc getContractAddressesForToken*(self: Controller, symbol: string): Table[int, proc getCommunityTokenList*(self: Controller): seq[CommunityTokenDto] = return self.communityTokensService.getCommunityTokens(self.getMySectionId()) - diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 830c7342ba..b696fa10f0 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -403,6 +403,7 @@ method onChatsLoaded*( let community = self.controller.getMyCommunity() self.view.setAmIMember(community.joined) self.initCommunityTokenPermissionsModel(channelGroup) + self.onCommunityCheckAllChannelsPermissionsResponse(channelGroup.channelPermissions) self.controller.asyncCheckPermissionsToJoin() let activeChatId = self.controller.getActiveChatId() @@ -895,8 +896,9 @@ proc updateChannelPermissionViewData*(self: Module, chatId: string, viewOnlyPerm self.updateTokenPermissionModel(viewAndPostPermissions.permissions, community) self.updateChatRequiresPermissions(chatId) self.updateChatLocked(chatId) - self.chatContentModules[chatId].onUpdateViewOnlyPermissionsSatisfied(viewOnlyPermissions.satisfied) - self.chatContentModules[chatId].onUpdateViewAndPostPermissionsSatisfied(viewAndPostPermissions.satisfied) + if self.chatContentModules.hasKey(chatId): + self.chatContentModules[chatId].onUpdateViewOnlyPermissionsSatisfied(viewOnlyPermissions.satisfied) + self.chatContentModules[chatId].onUpdateViewAndPostPermissionsSatisfied(viewAndPostPermissions.satisfied) method onCommunityCheckPermissionsToJoinResponse*(self: Module, checkPermissionsToJoinResponse: CheckPermissionsToJoinResponseDto) = let community = self.controller.getMyCommunity() @@ -921,10 +923,14 @@ method onCommunityTokenPermissionDeletionFailed*(self: Module, communityId: stri method onCommunityCheckChannelPermissionsResponse*(self: Module, chatId: string, checkChannelPermissionsResponse: CheckChannelPermissionsResponseDto) = let community = self.controller.getMyCommunity() - self.updateChannelPermissionViewData(chatId, checkChannelPermissionsResponse.viewOnlyPermissions, checkChannelPermissionsResponse.viewAndPostPermissions, community) + if community.id != "": + self.updateChannelPermissionViewData(chatId, checkChannelPermissionsResponse.viewOnlyPermissions, checkChannelPermissionsResponse.viewAndPostPermissions, community) method onCommunityCheckAllChannelsPermissionsResponse*(self: Module, checkAllChannelsPermissionsResponse: CheckAllChannelsPermissionsResponseDto) = let community = self.controller.getMyCommunity() + if community.id == "": + return + for chatId, permissionResult in checkAllChannelsPermissionsResponse.channels: self.updateChannelPermissionViewData(chatId, permissionResult.viewOnlyPermissions, permissionResult.viewAndPostPermissions, community) diff --git a/src/app_service/service/chat/async_tasks.nim b/src/app_service/service/chat/async_tasks.nim index dc3cfe7626..5166428a7e 100644 --- a/src/app_service/service/chat/async_tasks.nim +++ b/src/app_service/service/chat/async_tasks.nim @@ -13,3 +13,44 @@ const asyncGetChannelGroupsTask: Task = proc(argEncoded: string) {.gcsafe, nimca "channelGroups": response.result } arg.finish(responseJson) + +type + AsyncCheckChannelPermissionsTaskArg = ref object of QObjectTaskArg + communityId: string + chatId: string + +const asyncCheckChannelPermissionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = + let arg = decode[AsyncCheckChannelPermissionsTaskArg](argEncoded) + try: + let response = status_communities.checkCommunityChannelPermissions(arg.communityId, arg.chatId) + arg.finish(%* { + "response": response, + "communityId": arg.communityId, + "chatId": arg.chatId, + "error": "", + }) + except Exception as e: + arg.finish(%* { + "communityId": arg.communityId, + "chatId": arg.chatId, + "error": e.msg, + }) + +type + AsyncCheckAllChannelsPermissionsTaskArg = ref object of QObjectTaskArg + communityId: string + +const asyncCheckAllChannelsPermissionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = + let arg = decode[AsyncCheckAllChannelsPermissionsTaskArg](argEncoded) + try: + let response = status_communities.checkAllCommunityChannelsPermissions(arg.communityId) + arg.finish(%* { + "response": response, + "communityId": arg.communityId, + "error": "", + }) + except Exception as e: + arg.finish(%* { + "communityId": arg.communityId, + "error": e.msg, + }) diff --git a/src/app_service/service/chat/dto/chat.nim b/src/app_service/service/chat/dto/chat.nim index 92c5b307a7..4629fa1f90 100644 --- a/src/app_service/service/chat/dto/chat.nim +++ b/src/app_service/service/chat/dto/chat.nim @@ -1,6 +1,6 @@ {.used.} -import json, strformat, strutils +import json, strformat, strutils, tables import ../../community/dto/community include ../../../common/json_utils @@ -40,6 +40,20 @@ type ChatMember* = object joined*: bool role*: MemberRole +type CheckPermissionsResultDto* = object + criteria*: seq[bool] + +type ViewOnlyOrViewAndPostPermissionsResponseDto* = object + satisfied*: bool + permissions*: Table[string, CheckPermissionsResultDto] + +type CheckChannelPermissionsResponseDto* = object + viewOnlyPermissions*: ViewOnlyOrViewAndPostPermissionsResponseDto + viewAndPostPermissions*: ViewOnlyOrViewAndPostPermissionsResponseDto + +type CheckAllChannelsPermissionsResponseDto* = object + channels*: Table[string, CheckChannelPermissionsResponseDto] + type ChatDto* = object id*: string # ID is the id of the chat, for public chats it is the name e.g. status, # for one-to-one is the hex encoded public key and for group chats is a random @@ -98,6 +112,7 @@ type ChannelGroupDto* = object encrypted*: bool unviewedMessagesCount*: int unviewedMentionsCount*: int + channelPermissions*: CheckAllChannelsPermissionsResponseDto type ClearedHistoryDto* = object chatId*: string @@ -134,6 +149,34 @@ proc `$`*(self: ChatDto): string = highlight: {self.highlight} )""" +proc toCheckPermissionsResultDto*(jsonObj: JsonNode): CheckPermissionsResultDto = + result = CheckPermissionsResultDto() + var criteriaObj: JsonNode + if(jsonObj.getProp("criteria", criteriaObj) and criteriaObj.kind == JArray): + for c in criteriaObj: + result.criteria.add(c.getBool) + +proc toViewOnlyOrViewAndPostPermissionsResponseDto*(jsonObj: JsonNode): ViewOnlyOrViewAndPostPermissionsResponseDto = + result = ViewOnlyOrViewAndPostPermissionsResponseDto() + discard jsonObj.getProp("satisfied", result.satisfied) + + var permissionsObj: JsonNode + if(jsonObj.getProp("permissions", permissionsObj) and permissionsObj.kind == JObject): + result.permissions = initTable[string, CheckPermissionsResultDto]() + for permissionId, permission in permissionsObj: + result.permissions[permissionId] = permission.toCheckPermissionsResultDto + +proc toCheckChannelPermissionsResponseDto*(jsonObj: JsonNode): CheckChannelPermissionsResponseDto = + result = CheckChannelPermissionsResponseDto() + + var viewOnlyPermissionsObj: JsonNode + if(jsonObj.getProp("viewOnlyPermissions", viewOnlyPermissionsObj) and viewOnlyPermissionsObj.kind == JObject): + result.viewOnlyPermissions = viewOnlyPermissionsObj.toViewOnlyOrViewAndPostPermissionsResponseDto() + + var viewAndPostPermissionsObj: JsonNode + if(jsonObj.getProp("viewAndPostPermissions", viewAndPostPermissionsObj) and viewAndPostPermissionsObj.kind == JObject): + result.viewAndPostPermissions = viewAndPostPermissionsObj.toViewOnlyOrViewAndPostPermissionsResponseDto() + proc toClearedHistoryDto*(jsonObj: JsonNode): ClearedHistoryDto = result = ClearedHistoryDto() discard jsonObj.getProp("chatId", result.chatId) @@ -320,6 +363,15 @@ proc toChannelGroupDto*(jsonObj: JsonNode): ChannelGroupDto = discard jsonObj.getProp("color", result.color) discard jsonObj.getProp("muted", result.muted) + var responseDto = CheckAllChannelsPermissionsResponseDto() + responseDto.channels = initTable[string, CheckChannelPermissionsResponseDto]() + result.channelPermissions = responseDto + var checkChannelPermissionResponsesObj: JsonNode + if(jsonObj.getProp("checkChannelPermissionResponses", checkChannelPermissionResponsesObj) and checkChannelPermissionResponsesObj.kind == JObject): + + for channelId, permissionResponse in checkChannelPermissionResponsesObj: + result.channelPermissions.channels[channelId] = permissionResponse.toCheckChannelPermissionsResponseDto() + # To parse Community chats to ChatDto, we need to add the commuity ID and type proc toChatDto*(jsonObj: JsonNode, communityId: string): ChatDto = result = jsonObj.toChatDto() diff --git a/src/app_service/service/chat/service.nim b/src/app_service/service/chat/service.nim index 4f1931f97b..010db8b525 100644 --- a/src/app_service/service/chat/service.nim +++ b/src/app_service/service/chat/service.nim @@ -8,6 +8,7 @@ import ../activity_center/dto/notification as notification_dto import ../community/dto/community as community_dto import ../contacts/service as contact_service import ../../../backend/chat as status_chat +import ../../../backend/communities as status_communities import ../../../backend/group_chat as status_group_chat import ../../../backend/chatCommands as status_chat_commands import ../../../app/global/global_singleton @@ -86,6 +87,15 @@ type RpcResponseArgs* = ref object of Args response*: RpcResponse[JsonNode] + CheckChannelPermissionsResponseArgs* = ref object of Args + communityId*: string + chatId*: string + checkChannelPermissionsResponse*: CheckChannelPermissionsResponseDto + + CheckAllChannelsPermissionsResponseArgs* = ref object of Args + communityId*: string + checkAllChannelsPermissionsResponse*: CheckAllChannelsPermissionsResponseDto + # Signals which may be emitted by this service: const SIGNAL_CHANNEL_GROUPS_LOADED* = "channelGroupsLoaded" @@ -108,6 +118,8 @@ const SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT* = "switchToOrCreateOneToOneChat" const SIGNAL_CHAT_ADDED_OR_UPDATED* = "chatAddedOrUpdated" const SIGNAL_CHAT_CREATED* = "chatCreated" const SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND* = "chatRequestUpdateAfterSend" +const SIGNAL_CHECK_CHANNEL_PERMISSIONS_RESPONSE* = "checkChannelPermissionsResponse" +const SIGNAL_CHECK_ALL_CHANNELS_PERMISSIONS_RESPONSE* = "checkAllChannelsPermissionsResponse" QtObject: type Service* = ref object of QObject @@ -730,3 +742,56 @@ QtObject: chat.unviewedMessagesCount = max(0, chat.unviewedMessagesCount - markAsReadCount) chat.unviewedMentionsCount = max(0, chat.unviewedMentionsCount - markAsReadMentionsCount) self.updateOrAddChat(chat) + + proc asyncCheckChannelPermissions*(self: Service, communityId: string, chatId: string) = + let arg = AsyncCheckChannelPermissionsTaskArg( + tptr: cast[ByteAddress](asyncCheckChannelPermissionsTask), + vptr: cast[ByteAddress](self.vptr), + slot: "onAsyncCheckChannelPermissionsDone", + communityId: communityId, + chatId: chatId + ) + self.threadpool.start(arg) + + proc onAsyncCheckChannelPermissionsDone*(self: Service, rpcResponse: string) {.slot.} = + try: + let rpcResponseObj = rpcResponse.parseJson + if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "": + let error = Json.decode($rpcResponseObj["error"], RpcError) + error "Error checking community channel permissions", msg = error.message + return + + let communityId = rpcResponseObj{"communityId"}.getStr() + let chatId = rpcResponseObj{"chatId"}.getStr() + let checkChannelPermissionsResponse = rpcResponseObj["response"]["result"].toCheckChannelPermissionsResponseDto() + self.channelGroups[communityId].channelPermissions.channels[chatId] = checkChannelPermissionsResponse + self.events.emit(SIGNAL_CHECK_CHANNEL_PERMISSIONS_RESPONSE, CheckChannelPermissionsResponseArgs(communityId: communityId, chatId: chatId, checkChannelPermissionsResponse: checkChannelPermissionsResponse)) + except Exception as e: + let errMsg = e.msg + error "error checking all channel permissions: ", errMsg + + proc asyncCheckAllChannelsPermissions*(self: Service, communityId: string) = + let arg = AsyncCheckAllChannelsPermissionsTaskArg( + tptr: cast[ByteAddress](asyncCheckAllChannelsPermissionsTask), + vptr: cast[ByteAddress](self.vptr), + slot: "onAsyncCheckAllChannelsPermissionsDone", + communityId: communityId + ) + self.threadpool.start(arg) + + proc onAsyncCheckAllChannelsPermissionsDone*(self: Service, rpcResponse: string) {.slot.} = + try: + let rpcResponseObj = rpcResponse.parseJson + if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "": + let error = Json.decode($rpcResponseObj["error"], RpcError) + error "Error checking all community channel permissions", msg = error.message + return + + let communityId = rpcResponseObj{"communityId"}.getStr() + let checkAllChannelsPermissionsResponse = rpcResponseObj["response"]["result"].toCheckAllChannelsPermissionsResponseDto() + self.channelGroups[communityId].channelPermissions = checkAllChannelsPermissionsResponse + self.events.emit(SIGNAL_CHECK_ALL_CHANNELS_PERMISSIONS_RESPONSE, CheckAllChannelsPermissionsResponseArgs(communityId: communityId, checkAllChannelsPermissionsResponse: checkAllChannelsPermissionsResponse)) + except Exception as e: + let errMsg = e.msg + error "error checking all channels permissions: ", errMsg + diff --git a/src/app_service/service/community/async_tasks.nim b/src/app_service/service/community/async_tasks.nim index 2b3fcb604c..3b737dbbe0 100644 --- a/src/app_service/service/community/async_tasks.nim +++ b/src/app_service/service/community/async_tasks.nim @@ -121,44 +121,3 @@ const asyncCheckPermissionsToJoinTask: Task = proc(argEncoded: string) {.gcsafe, "communityId": arg.communityId, "error": e.msg, }) - -type - AsyncCheckChannelPermissionsTaskArg = ref object of QObjectTaskArg - communityId: string - chatId: string - -const asyncCheckChannelPermissionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = - let arg = decode[AsyncCheckChannelPermissionsTaskArg](argEncoded) - try: - let response = status_go.checkCommunityChannelPermissions(arg.communityId, arg.chatId) - arg.finish(%* { - "response": response, - "communityId": arg.communityId, - "chatId": arg.chatId, - "error": "", - }) - except Exception as e: - arg.finish(%* { - "communityId": arg.communityId, - "chatId": arg.chatId, - "error": e.msg, - }) - -type - AsyncCheckAllChannelsPermissionsTaskArg = ref object of QObjectTaskArg - communityId: string - -const asyncCheckAllChannelsPermissionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = - let arg = decode[AsyncCheckAllChannelsPermissionsTaskArg](argEncoded) - try: - let response = status_go.checkAllCommunityChannelsPermissions(arg.communityId) - arg.finish(%* { - "response": response, - "communityId": arg.communityId, - "error": "", - }) - except Exception as e: - arg.finish(%* { - "communityId": arg.communityId, - "error": e.msg, - }) diff --git a/src/app_service/service/community/dto/community.nim b/src/app_service/service/community/dto/community.nim index 0aae6a9002..e5112cbc5c 100644 --- a/src/app_service/service/community/dto/community.nim +++ b/src/app_service/service/community/dto/community.nim @@ -83,25 +83,11 @@ type AccountChainIDsCombinationDto* = object address*: string chainIds*: seq[int] -type CheckPermissionsResultDto* = object - criteria*: seq[bool] - type CheckPermissionsToJoinResponseDto* = object satisfied*: bool permissions*: Table[string, CheckPermissionsResultDto] validCombinations*: seq[AccountChainIDsCombinationDto] -type ViewOnlyOrViewAndPostPermissionsResponseDto* = object - satisfied*: bool - permissions*: Table[string, CheckPermissionsResultDto] - -type CheckChannelPermissionsResponseDto* = object - viewOnlyPermissions*: ViewOnlyOrViewAndPostPermissionsResponseDto - viewAndPostPermissions*: ViewOnlyOrViewAndPostPermissionsResponseDto - -type CheckAllChannelsPermissionsResponseDto* = object - channels*: Table[string, CheckChannelPermissionsResponseDto] - type CommunityDto* = object id*: string memberRole*: MemberRole @@ -282,13 +268,6 @@ proc toCommunityTokenPermissionDto*(jsonObj: JsonNode): CommunityTokenPermission if jsonObj.hasKey("key"): discard jsonObj.getProp("key", result.id) -proc toCheckPermissionsResultDto*(jsonObj: JsonNode): CheckPermissionsResultDto = - result = CheckPermissionsResultDto() - var criteriaObj: JsonNode - if(jsonObj.getProp("criteria", criteriaObj) and criteriaObj.kind == JArray): - for c in criteriaObj: - result.criteria.add(c.getBool) - proc toAccountChainIDsCombinationDto*(jsonObj: JsonNode): AccountChainIDsCombinationDto = result = AccountChainIDsCombinationDto() discard jsonObj.getProp("address", result.address) @@ -312,27 +291,6 @@ proc toCheckPermissionsToJoinResponseDto*(jsonObj: JsonNode): CheckPermissionsTo for permissionId, permission in permissionsObj: result.permissions[permissionId] = permission.toCheckPermissionsResultDto -proc toViewOnlyOrViewAndPostPermissionsResponseDto*(jsonObj: JsonNode): ViewOnlyOrViewAndPostPermissionsResponseDto = - result = ViewOnlyOrViewAndPostPermissionsResponseDto() - discard jsonObj.getProp("satisfied", result.satisfied) - - var permissionsObj: JsonNode - if(jsonObj.getProp("permissions", permissionsObj) and permissionsObj.kind == JObject): - result.permissions = initTable[string, CheckPermissionsResultDto]() - for permissionId, permission in permissionsObj: - result.permissions[permissionId] = permission.toCheckPermissionsResultDto - -proc toCheckChannelPermissionsResponseDto*(jsonObj: JsonNode): CheckChannelPermissionsResponseDto = - result = CheckChannelPermissionsResponseDto() - - var viewOnlyPermissionsObj: JsonNode - if(jsonObj.getProp("viewOnlyPermissions", viewOnlyPermissionsObj) and viewOnlyPermissionsObj.kind == JObject): - result.viewOnlyPermissions = viewOnlyPermissionsObj.toViewOnlyOrViewAndPostPermissionsResponseDto() - - var viewAndPostPermissionsObj: JsonNode - if(jsonObj.getProp("viewAndPostPermissions", viewAndPostPermissionsObj) and viewAndPostPermissionsObj.kind == JObject): - result.viewAndPostPermissions = viewAndPostPermissionsObj.toViewOnlyOrViewAndPostPermissionsResponseDto() - proc toCheckAllChannelsPermissionsResponseDto*(jsonObj: JsonNode): CheckAllChannelsPermissionsResponseDto = result = CheckAllChannelsPermissionsResponseDto() result.channels = initTable[string, CheckChannelPermissionsResponseDto]() diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index d505682014..59bc41b18c 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -117,15 +117,6 @@ type communityId*: string checkPermissionsToJoinResponse*: CheckPermissionsToJoinResponseDto - CheckChannelPermissionsResponseArgs* = ref object of Args - communityId*: string - chatId*: string - checkChannelPermissionsResponse*: CheckChannelPermissionsResponseDto - - CheckAllChannelsPermissionsResponseArgs* = ref object of Args - communityId*: string - checkAllChannelsPermissionsResponse*: CheckAllChannelsPermissionsResponseDto - # Signals which may be emitted by this service: const SIGNAL_COMMUNITY_DATA_LOADED* = "communityDataLoaded" const SIGNAL_COMMUNITY_JOINED* = "communityJoined" @@ -188,8 +179,6 @@ const TOKEN_PERMISSIONS_ADDED = "tokenPermissionsAdded" const TOKEN_PERMISSIONS_MODIFIED = "tokenPermissionsModified" const SIGNAL_CHECK_PERMISSIONS_TO_JOIN_RESPONSE* = "checkPermissionsToJoinResponse" -const SIGNAL_CHECK_CHANNEL_PERMISSIONS_RESPONSE* = "checkChannelPermissionsResponse" -const SIGNAL_CHECK_ALL_CHANNELS_PERMISSIONS_RESPONSE* = "checkAllChannelsPermissionsResponse" QtObject: type @@ -1408,59 +1397,6 @@ QtObject: let errMsg = e.msg error "error checking permissions to join: ", errMsg - proc asyncCheckChannelPermissions*(self: Service, communityId: string, chatId: string) = - let arg = AsyncCheckChannelPermissionsTaskArg( - tptr: cast[ByteAddress](asyncCheckChannelPermissionsTask), - vptr: cast[ByteAddress](self.vptr), - slot: "onAsyncCheckChannelPermissionsDone", - communityId: communityId, - chatId: chatId - ) - self.threadpool.start(arg) - - proc onAsyncCheckChannelPermissionsDone*(self: Service, rpcResponse: string) {.slot.} = - try: - let rpcResponseObj = rpcResponse.parseJson - if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "": - let error = Json.decode($rpcResponseObj["error"], RpcError) - error "Error checking community channel permissions", msg = error.message - return - - let communityId = rpcResponseObj{"communityId"}.getStr() - let chatId = rpcResponseObj{"chatId"}.getStr() - let checkChannelPermissionsResponse = rpcResponseObj["response"]["result"].toCheckChannelPermissionsResponseDto() - self.communities[communityId].channelPermissions.channels[chatId] = checkChannelPermissionsResponse - self.events.emit(SIGNAL_CHECK_CHANNEL_PERMISSIONS_RESPONSE, CheckChannelPermissionsResponseArgs(communityId: communityId, chatId: chatId, checkChannelPermissionsResponse: checkChannelPermissionsResponse)) - except Exception as e: - let errMsg = e.msg - error "error checking all channel permissions: ", errMsg - - proc asyncCheckAllChannelsPermissions*(self: Service, communityId: string) = - let arg = AsyncCheckAllChannelsPermissionsTaskArg( - tptr: cast[ByteAddress](asyncCheckAllChannelsPermissionsTask), - vptr: cast[ByteAddress](self.vptr), - slot: "onAsyncCheckAllChannelsPermissionsDone", - communityId: communityId - ) - self.threadpool.start(arg) - - proc onAsyncCheckAllChannelsPermissionsDone*(self: Service, rpcResponse: string) {.slot.} = - try: - let rpcResponseObj = rpcResponse.parseJson - if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "": - let error = Json.decode($rpcResponseObj["error"], RpcError) - error "Error checking all community channel permissions", msg = error.message - return - - let communityId = rpcResponseObj{"communityId"}.getStr() - let checkAllChannelsPermissionsResponse = rpcResponseObj["response"]["result"].toCheckAllChannelsPermissionsResponseDto() - self.communities[communityId].channelPermissions = checkAllChannelsPermissionsResponse - self.events.emit(SIGNAL_CHECK_ALL_CHANNELS_PERMISSIONS_RESPONSE, CheckAllChannelsPermissionsResponseArgs(communityId: communityId, checkAllChannelsPermissionsResponse: checkAllChannelsPermissionsResponse)) - - except Exception as e: - let errMsg = e.msg - error "error checking all channels permissions: ", errMsg - proc asyncRequestToJoinCommunity*(self: Service, communityId: string, ensName: string, password: string) = try: let arg = AsyncRequestToJoinCommunityTaskArg( diff --git a/src/backend/communities.nim b/src/backend/communities.nim index 52c798390a..e960709502 100644 --- a/src/backend/communities.nim +++ b/src/backend/communities.nim @@ -395,3 +395,5 @@ proc getCommunitiesSettings*(): RpcResponse[JsonNode] {.raises: [Exception].} = proc requestExtractDiscordChannelsAndCategories*(filesToImport: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} = return callPrivateRPC("requestExtractDiscordChannelsAndCategories".prefix, %*[filesToImport]) +proc getCheckChannelPermissionResponses*(communityId: string,): RpcResponse[JsonNode] {.raises: [Exception].} = + return callPrivateRPC("getCheckChannelPermissionResponses".prefix, %*[communityId])