fix: prevent spam of "requested community doesn't exists"

The spam was caused by calling `getCommunityById` with empty id.
This commit is contained in:
Patryk Osmaczko 2023-02-16 21:33:33 +01:00 committed by osmaczko
parent c83794470b
commit 5bf702fd09
1 changed files with 4 additions and 1 deletions

View File

@ -206,7 +206,6 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
if message.deleted or message.deletedForMe:
continue
let chatDetails = self.controller.getChatDetails()
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
let sender = self.controller.getContactDetails(message.`from`)
var quotedMessageAuthorDetails = ContactDetails()
@ -216,6 +215,10 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
else:
quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`)
var communityChats: seq[ChatDto]
if chatDetails.communityId != "":
communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
var transactionContract = message.transactionParameters.contract
var transactionValue = message.transactionParameters.value