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,16 +932,14 @@ QtObject:
if(communitiesSettingsJArr.len == 0): if(communitiesSettingsJArr.len == 0):
raise newException(RpcException, fmt"`communitiesSettings` array is empty in the response for community id: {communityKey}") 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() var communityDto = communityJArr[0].toCommunityDto()
let communitySettingsDto = communitiesSettingsJArr[0].toCommunitySettingsDto() let communitySettingsDto = communitiesSettingsJArr[0].toCommunitySettingsDto()
communityDto.settings = communitySettingsDto communityDto.settings = communitySettingsDto
self.joinedCommunities[communityDto.id] = communityDto self.joinedCommunities[communityDto.id] = communityDto
var chatsJArr: JsonNode
if(response.result.getProp("chats", chatsJArr)):
for chatObj in chatsJArr: for chatObj in chatsJArr:
let chatDto = chatObj.toChatDto(communityDto.id) let chatDto = chatObj.toChatDto(communityDto.id)
self.chatService.updateOrAddChat(chatDto) # we have to update chats stored in the chat service. self.chatService.updateOrAddChat(chatDto) # we have to update chats stored in the chat service.