fix(Communities): Fix import community without chats

Closes: #5818
This commit is contained in:
Boris Melnik 2022-05-30 15:40:00 +03:00 committed by Iuri Matias
parent 1c85bd38b3
commit 781e57e776
1 changed files with 5 additions and 7 deletions

View File

@ -932,19 +932,17 @@ QtObject:
if(communitiesSettingsJArr.len == 0):
raise newException(RpcException, fmt"`communitiesSettings` array is empty in the response for community id: {communityKey}")
var chatsJArr: JsonNode
if(not response.result.getProp("chats", chatsJArr)):
raise newException(RpcException, fmt"there is no `chats` key in the response for community id: {communityKey}")
var communityDto = communityJArr[0].toCommunityDto()
let communitySettingsDto = communitiesSettingsJArr[0].toCommunitySettingsDto()
communityDto.settings = communitySettingsDto
self.joinedCommunities[communityDto.id] = communityDto
for chatObj in chatsJArr:
let chatDto = chatObj.toChatDto(communityDto.id)
self.chatService.updateOrAddChat(chatDto) # we have to update chats stored in the chat service.
var chatsJArr: JsonNode
if(response.result.getProp("chats", chatsJArr)):
for chatObj in chatsJArr:
let chatDto = chatObj.toChatDto(communityDto.id)
self.chatService.updateOrAddChat(chatDto) # we have to update chats stored in the chat service.
for chat in communityDto.chats:
let fullChatId = communityDto.id & chat.id