mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 06:16:32 +00:00
refactor(messages): create a helper MessageItem init function (#17008)
Fixes #14039 Creates a util function to create MessageItems.
This commit is contained in:
parent
8a0392f48b
commit
febe08882d
@ -3,9 +3,8 @@ import NimQml, Tables, json, sequtils
|
||||
import ./io_interface, ./view, ./controller, ./token_data_item
|
||||
import ../io_interface as delegate_interface
|
||||
import ./item as notification_item
|
||||
import ../../shared_models/message_item as msg_item
|
||||
import ../../shared_models/message_model
|
||||
import ../../shared_models/message_item_qobject as msg_item_qobj
|
||||
import ../../shared_models/message_transaction_parameters_item
|
||||
import ../../../global/global_singleton
|
||||
import ../../../global/app_sections_config as conf
|
||||
import ../../../core/eventemitter
|
||||
@ -100,69 +99,27 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: st
|
||||
else:
|
||||
quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`)
|
||||
|
||||
var imagesAlbum: seq[string]
|
||||
var albumImages: seq[string]
|
||||
var albumMessageIds: seq[string]
|
||||
if message.albumId != "":
|
||||
for msg in albumMessages:
|
||||
imagesAlbum.add(msg.image)
|
||||
albumImages.add(msg.image)
|
||||
albumMessageIds.add(msg.id)
|
||||
|
||||
return msg_item_qobj.newMessageItem(msg_item.initMessageItem(
|
||||
message.id,
|
||||
communityId, # we don't received community id via `activityCenterNotifications` api call
|
||||
message.chatId,
|
||||
message.responseTo,
|
||||
message.`from`,
|
||||
contactDetails.defaultDisplayName,
|
||||
contactDetails.optionalName,
|
||||
contactDetails.icon,
|
||||
contactDetails.colorHash,
|
||||
let messageItem = message_model.createMessageItemFromDtos(
|
||||
message,
|
||||
communityId,
|
||||
contactDetails,
|
||||
contactDetails.isCurrentUser,
|
||||
contactDetails.dto.added,
|
||||
message.outgoingStatus,
|
||||
self.controller.getRenderedText(message.parsedText, communityChats),
|
||||
self.controller.replacePubKeysWithDisplayNames(message.text),
|
||||
message.parsedText,
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
message.seen,
|
||||
timestamp = message.timestamp,
|
||||
clock = message.clock,
|
||||
message.contentType,
|
||||
message.messageType,
|
||||
message.contactRequestState,
|
||||
message.sticker.url,
|
||||
message.sticker.pack,
|
||||
message.links,
|
||||
message.linkPreviews,
|
||||
newTransactionParametersItem("","","","","","",-1,""),
|
||||
message.mentionedUsersPks,
|
||||
contactDetails.dto.trustStatus,
|
||||
contactDetails.dto.ensVerified,
|
||||
message.discordMessage,
|
||||
resendError = "",
|
||||
message.deleted,
|
||||
message.deletedBy,
|
||||
deletedByContactDetails = ContactDetails(),
|
||||
message.pinnedBy,
|
||||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
quotedMessageAuthorDetails,
|
||||
message.quotedMessage.albumImages,
|
||||
message.quotedMessage.albumImagesCount,
|
||||
message.albumId,
|
||||
imagesAlbum,
|
||||
renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats),
|
||||
clearText = self.controller.replacePubKeysWithDisplayNames(message.text),
|
||||
albumImages,
|
||||
albumMessageIds,
|
||||
message.albumImagesCount,
|
||||
message.bridgeMessage,
|
||||
message.quotedMessage.bridgeMessage,
|
||||
message.paymentRequests
|
||||
))
|
||||
deletedByContactDetails = ContactDetails(),
|
||||
quotedMessageAuthorDetails,
|
||||
quotedRenderedMessageText = self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
)
|
||||
return msg_item_qobj.newMessageItem(messageItem)
|
||||
|
||||
method convertToItems*(
|
||||
self: Module,
|
||||
|
@ -2,10 +2,8 @@ import NimQml, chronicles, sequtils, uuids, sets, times, tables, system
|
||||
import io_interface
|
||||
import ../io_interface as delegate_interface
|
||||
import view, controller
|
||||
import ../../../../shared_models/message_model
|
||||
import ../../../../shared_models/message_item
|
||||
import ../../../../shared_models/[message_model, message_item]
|
||||
import ../../../../shared_models/message_reaction_item
|
||||
import ../../../../shared_models/message_transaction_parameters_item
|
||||
import ../../../../shared_models/link_preview_model
|
||||
import ../../../../../global/global_singleton
|
||||
import ../../../../../core/eventemitter
|
||||
@ -16,6 +14,7 @@ import ../../../../../../app_service/service/chat/service as chat_service
|
||||
import ../../../../../../app_service/service/message/service as message_service
|
||||
import ../../../../../../app_service/service/mailservers/service as mailservers_service
|
||||
import ../../../../../../app_service/service/shared_urls/service as shared_urls_service
|
||||
import ../../../../../../app_service/service/contacts/dto/contact_details
|
||||
import ../../../../../../app_service/common/types
|
||||
import ../../../../../global/utils as utils
|
||||
import ../../../../../global/global_singleton
|
||||
@ -149,69 +148,21 @@ proc createMessageItemsFromMessageDtos(self: Module, messages: seq[MessageDto],
|
||||
if message.transactionParameters.fromAddress != "":
|
||||
isCurrentUser = self.currentUserWalletContainsAddress(message.transactionParameters.fromAddress)
|
||||
|
||||
var item = initMessageItem(
|
||||
message.id,
|
||||
message.chatId,
|
||||
var item = message_model.createMessageItemFromDtos(
|
||||
message,
|
||||
message.communityId,
|
||||
message.responseTo,
|
||||
message.`from`,
|
||||
sender.defaultDisplayName,
|
||||
sender.optionalName,
|
||||
sender.icon,
|
||||
sender.colorHash,
|
||||
(isCurrentUser and message.contentType != ContentType.DiscordMessage),
|
||||
sender.dto.added,
|
||||
message.outgoingStatus,
|
||||
sender,
|
||||
isCurrentUser,
|
||||
renderedMessageText,
|
||||
message.text,
|
||||
message.parsedText,
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
message.seen,
|
||||
timestamp = message.timestamp,
|
||||
clock = message.clock,
|
||||
message.contentType,
|
||||
message.messageType,
|
||||
message.contactRequestState,
|
||||
sticker = message.sticker.url,
|
||||
message.sticker.pack,
|
||||
message.links,
|
||||
message.linkPreviews,
|
||||
newTransactionParametersItem(message.transactionParameters.id,
|
||||
message.transactionParameters.fromAddress,
|
||||
message.transactionParameters.address,
|
||||
transactionContract,
|
||||
transactionValue,
|
||||
message.transactionParameters.transactionHash,
|
||||
message.transactionParameters.commandState,
|
||||
message.transactionParameters.signature),
|
||||
message.mentionedUsersPks(),
|
||||
sender.dto.trustStatus,
|
||||
sender.dto.ensVerified,
|
||||
message.discordMessage,
|
||||
resendError = "",
|
||||
message.deleted,
|
||||
message.deletedBy,
|
||||
clearText = message.text,
|
||||
albumImages = @[],
|
||||
albumMessageIds = @[],
|
||||
deletedByContactDetails,
|
||||
message.pinnedBy,
|
||||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
quotedMessageAuthorDetails,
|
||||
message.quotedMessage.albumImages,
|
||||
message.quotedMessage.albumImagesCount,
|
||||
message.albumId,
|
||||
if (len(message.albumId) == 0): @[] else: @[message.image],
|
||||
if (len(message.albumId) == 0): @[] else: @[message.id],
|
||||
message.albumImagesCount,
|
||||
message.bridgeMessage,
|
||||
message.quotedMessage.bridgeMessage,
|
||||
message.paymentRequests
|
||||
)
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
transactionContract,
|
||||
transactionValue,
|
||||
)
|
||||
|
||||
self.updateLinkPreviewsContacts(item, requestFromMailserver = item.seen)
|
||||
self.updateLinkPreviewsCommunities(item, requestFromMailserver = item.seen)
|
||||
@ -239,61 +190,21 @@ proc createMessageItemsFromMessageDtos(self: Module, messages: seq[MessageDto],
|
||||
|
||||
proc createFetchMoreMessagesItem(self: Module): Item =
|
||||
let chatDto = self.controller.getChatDetails()
|
||||
result = initMessageItem(
|
||||
FETCH_MORE_MESSAGES_MESSAGE_ID,
|
||||
result = message_model.createMessageItemFromDtos(
|
||||
message = MessageDto(
|
||||
id: FETCH_MORE_MESSAGES_MESSAGE_ID,
|
||||
clock: FETCH_MORE_MESSAGES_CLOCK,
|
||||
contentType: ContentType.FetchMoreMessagesButton,
|
||||
),
|
||||
communityId = "",
|
||||
chatId = "",
|
||||
responseToMessageWithId = "",
|
||||
senderId = chatDto.id,
|
||||
senderDisplayName = "",
|
||||
senderOptionalName = "",
|
||||
senderIcon = "",
|
||||
senderColorHash = "",
|
||||
amISender = false,
|
||||
senderIsAdded = false,
|
||||
outgoingStatus = "",
|
||||
text = "",
|
||||
unparsedText = "",
|
||||
parsedText = @[],
|
||||
image = "",
|
||||
messageContainsMentions = false,
|
||||
seen = true,
|
||||
timestamp = 0,
|
||||
clock = FETCH_MORE_MESSAGES_CLOCK,
|
||||
ContentType.FetchMoreMessagesButton,
|
||||
messageType = -1,
|
||||
contactRequestState = 0,
|
||||
sticker = "",
|
||||
stickerPack = -1,
|
||||
links = @[],
|
||||
linkPreviews = @[],
|
||||
transactionParameters = newTransactionParametersItem("","","","","","",-1,""),
|
||||
mentionedUsersPks = @[],
|
||||
senderTrustStatus = TrustStatus.Unknown,
|
||||
senderEnsVerified = false,
|
||||
DiscordMessage(),
|
||||
resendError = "",
|
||||
deleted = false,
|
||||
deletedBy = "",
|
||||
deletedByContactDetails = ContactDetails(),
|
||||
pinnedBy = "",
|
||||
mentioned = false,
|
||||
quotedMessageFrom = "",
|
||||
quotedMessageText = "",
|
||||
quotedMessageParsedText = "",
|
||||
quotedMessageContentType = ContentType.Unknown,
|
||||
quotedMessageDeleted = false,
|
||||
quotedMessageDiscordMessage = DiscordMessage(),
|
||||
quotedMessageAuthorDetails = ContactDetails(),
|
||||
quotedMessageAlbumMessageImages = @[],
|
||||
quotedMessageAlbumImagesCount = 0,
|
||||
albumId = "",
|
||||
albumMessageImages = @[],
|
||||
albumMessageIds = @[],
|
||||
albumImagesCount = 0,
|
||||
BridgeMessage(),
|
||||
BridgeMessage(),
|
||||
paymentRequests = @[]
|
||||
sender = ContactDetails(
|
||||
dto: ContactsDto(
|
||||
id: chatDto.id,
|
||||
),
|
||||
),
|
||||
isCurrentUser = false,
|
||||
renderedMessageText = "",
|
||||
clearText = "",
|
||||
)
|
||||
|
||||
proc createChatIdentifierItem(self: Module): Item =
|
||||
@ -303,67 +214,32 @@ proc createChatIdentifierItem(self: Module): Item =
|
||||
var chatIcon = ""
|
||||
var senderColorHash = ""
|
||||
var senderIsAdded = false
|
||||
if(chatDto.chatType == ChatType.OneToOne):
|
||||
if chatDto.chatType == ChatType.OneToOne:
|
||||
let sender = self.controller.getContactDetails(chatDto.id)
|
||||
senderIsAdded = sender.dto.added
|
||||
(chatName, smallImage, chatIcon) = self.controller.getOneToOneChatNameAndImage()
|
||||
senderColorHash = sender.colorHash
|
||||
|
||||
result = initMessageItem(
|
||||
CHAT_IDENTIFIER_MESSAGE_ID,
|
||||
result = message_model.createMessageItemFromDtos(
|
||||
message = MessageDto(
|
||||
id: CHAT_IDENTIFIER_MESSAGE_ID,
|
||||
clock: CHAT_IDENTIFIER_CLOCK,
|
||||
contentType: ContentType.ChatIdentifier,
|
||||
seen: true,
|
||||
),
|
||||
communityId = "",
|
||||
chatId = "",
|
||||
responseToMessageWithId = "",
|
||||
senderId = chatDto.id,
|
||||
senderDisplayName = chatName,
|
||||
senderOptionalName = "",
|
||||
senderIcon = chatIcon,
|
||||
senderColorHash = senderColorHash,
|
||||
amISender = false,
|
||||
senderIsAdded,
|
||||
outgoingStatus = "",
|
||||
text = "",
|
||||
unparsedText = "",
|
||||
parsedText = @[],
|
||||
image = "",
|
||||
messageContainsMentions = false,
|
||||
seen = true,
|
||||
timestamp = 0,
|
||||
clock = CHAT_IDENTIFIER_CLOCK,
|
||||
ContentType.ChatIdentifier,
|
||||
messageType = -1,
|
||||
contactRequestState = 0,
|
||||
sticker = "",
|
||||
stickerPack = -1,
|
||||
links = @[],
|
||||
linkPreviews = @[],
|
||||
transactionParameters = newTransactionParametersItem("","","","","","",-1,""),
|
||||
mentionedUsersPks = @[],
|
||||
senderTrustStatus = TrustStatus.Unknown,
|
||||
senderEnsVerified = false,
|
||||
DiscordMessage(),
|
||||
resendError = "",
|
||||
deleted = false,
|
||||
deletedBy = "",
|
||||
deletedByContactDetails = ContactDetails(),
|
||||
pinnedBy = "",
|
||||
mentioned = false,
|
||||
quotedMessageFrom = "",
|
||||
quotedMessageText = "",
|
||||
quotedMessageParsedText = "",
|
||||
quotedMessageContentType = ContentType.Unknown,
|
||||
quotedMessageDeleted = false,
|
||||
quotedMessageDiscordMessage = DiscordMessage(),
|
||||
quotedMessageAuthorDetails = ContactDetails(),
|
||||
quotedMessageAlbumMessageImages = @[],
|
||||
quotedMessageAlbumImagesCount = 0,
|
||||
albumId = "",
|
||||
albumMessageImages = @[],
|
||||
albumMessageIds = @[],
|
||||
albumImagesCount = 0,
|
||||
bridgeMessage = BridgeMessage(),
|
||||
quotedBridgeMessage = BridgeMessage(),
|
||||
paymentRequests = @[]
|
||||
sender = ContactDetails(
|
||||
defaultDisplayName: chatName,
|
||||
icon: chatIcon,
|
||||
colorHash: senderColorHash,
|
||||
dto: ContactsDto(
|
||||
id: chatDto.id,
|
||||
added: senderIsAdded,
|
||||
),
|
||||
),
|
||||
isCurrentUser = false,
|
||||
renderedMessageText = "",
|
||||
clearText = "",
|
||||
)
|
||||
|
||||
proc checkIfMessageLoadedAndScroll(self: Module) =
|
||||
|
@ -7,7 +7,6 @@ import ../item as chat_item
|
||||
import ./chat_details
|
||||
import ../../../shared_models/message_model as pinned_msg_model
|
||||
import ../../../shared_models/message_item as pinned_msg_item
|
||||
import ../../../shared_models/message_transaction_parameters_item
|
||||
import ../../../shared_models/message_reaction_item as pinned_msg_reaction_item
|
||||
import ../../../../global/global_singleton
|
||||
import ../../../../core/eventemitter
|
||||
@ -175,68 +174,21 @@ proc buildPinnedMessageItem(self: Module, message: MessageDto, actionInitiatedBy
|
||||
(transactionContract, transactionValue) = self.controller.getTransactionDetails(message)
|
||||
if message.transactionParameters.fromAddress != "":
|
||||
isCurrentUser = self.currentUserWalletContainsAddress(message.transactionParameters.fromAddress)
|
||||
item = pinned_msg_item.initMessageItem(
|
||||
message.id,
|
||||
|
||||
item = pinned_msg_model.createMessageItemFromDtos(
|
||||
message,
|
||||
message.communityId,
|
||||
message.chatId,
|
||||
message.responseTo,
|
||||
message.`from`,
|
||||
contactDetails.defaultDisplayName,
|
||||
contactDetails.optionalName,
|
||||
contactDetails.icon,
|
||||
contactDetails.colorHash,
|
||||
contactDetails,
|
||||
isCurrentUser,
|
||||
contactDetails.dto.added,
|
||||
message.outgoingStatus,
|
||||
self.controller.getRenderedText(message.parsedText, communityChats),
|
||||
message.text,
|
||||
message.parsedText,
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
message.seen,
|
||||
timestamp = message.timestamp,
|
||||
clock = message.clock,
|
||||
message.contentType,
|
||||
message.messageType,
|
||||
message.contactRequestState,
|
||||
message.sticker.url,
|
||||
message.sticker.pack,
|
||||
message.links,
|
||||
message.linkPreviews,
|
||||
newTransactionParametersItem(message.transactionParameters.id,
|
||||
message.transactionParameters.fromAddress,
|
||||
message.transactionParameters.address,
|
||||
transactionContract,
|
||||
transactionValue,
|
||||
message.transactionParameters.transactionHash,
|
||||
message.transactionParameters.commandState,
|
||||
message.transactionParameters.signature),
|
||||
message.mentionedUsersPks,
|
||||
contactDetails.dto.trustStatus,
|
||||
contactDetails.dto.ensVerified,
|
||||
message.discordMessage,
|
||||
resendError = "",
|
||||
message.deleted,
|
||||
message.deletedBy,
|
||||
clearText = message.text,
|
||||
albumImages = @[],
|
||||
albumMessageIds = @[],
|
||||
deletedByContactDetails = ContactDetails(),
|
||||
message.pinnedBy,
|
||||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
quotedMessageAuthorDetails,
|
||||
message.quotedMessage.albumImages,
|
||||
message.quotedMessage.albumImagesCount,
|
||||
message.albumId,
|
||||
if (len(message.albumId) == 0): @[] else: @[message.image],
|
||||
if (len(message.albumId) == 0): @[] else: @[message.id],
|
||||
message.albumImagesCount,
|
||||
message.bridgeMessage,
|
||||
message.quotedMessage.bridgeMessage,
|
||||
message.paymentRequests
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
transactionContract,
|
||||
transactionValue,
|
||||
)
|
||||
item.pinned = true
|
||||
item.pinnedBy = actionInitiatedBy
|
||||
|
@ -7,7 +7,6 @@ import model as chats_model
|
||||
import item as chat_item
|
||||
import ../../shared_models/message_item as member_msg_item
|
||||
import ../../shared_models/message_model as member_msg_model
|
||||
import ../../shared_models/message_transaction_parameters_item
|
||||
import ../../shared_models/user_item as user_item
|
||||
import ../../shared_models/user_model as user_model
|
||||
import ../../shared_models/token_permissions_model
|
||||
@ -156,68 +155,21 @@ proc buildCommunityMemberMessageItem(self: Module, message: MessageDto): member_
|
||||
(transactionContract, transactionValue) = self.controller.getTransactionDetails(message)
|
||||
if message.transactionParameters.fromAddress != "":
|
||||
isCurrentUser = self.currentUserWalletContainsAddress(message.transactionParameters.fromAddress)
|
||||
return member_msg_item.initMessageItem(
|
||||
message.id,
|
||||
|
||||
return member_msg_model.createMessageItemFromDtos(
|
||||
message,
|
||||
message.communityId,
|
||||
message.chatId,
|
||||
message.responseTo,
|
||||
message.`from`,
|
||||
contactDetails.defaultDisplayName,
|
||||
contactDetails.optionalName,
|
||||
contactDetails.icon,
|
||||
contactDetails.colorHash,
|
||||
contactDetails,
|
||||
isCurrentUser,
|
||||
contactDetails.dto.added,
|
||||
message.outgoingStatus,
|
||||
self.controller.getRenderedText(message.parsedText, communityChats),
|
||||
message.text,
|
||||
message.parsedText,
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
message.seen,
|
||||
timestamp = message.timestamp,
|
||||
clock = message.clock,
|
||||
message.contentType,
|
||||
message.messageType,
|
||||
message.contactRequestState,
|
||||
message.sticker.url,
|
||||
message.sticker.pack,
|
||||
message.links,
|
||||
message.linkPreviews,
|
||||
newTransactionParametersItem(message.transactionParameters.id,
|
||||
message.transactionParameters.fromAddress,
|
||||
message.transactionParameters.address,
|
||||
transactionContract,
|
||||
transactionValue,
|
||||
message.transactionParameters.transactionHash,
|
||||
message.transactionParameters.commandState,
|
||||
message.transactionParameters.signature),
|
||||
message.mentionedUsersPks,
|
||||
contactDetails.dto.trustStatus,
|
||||
contactDetails.dto.ensVerified,
|
||||
message.discordMessage,
|
||||
resendError = "",
|
||||
message.deleted,
|
||||
message.deletedBy,
|
||||
clearText = message.text,
|
||||
albumImages = @[],
|
||||
albumMessageIds = @[],
|
||||
deletedByContactDetails = ContactDetails(),
|
||||
message.pinnedBy,
|
||||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
quotedMessageAuthorDetails,
|
||||
message.quotedMessage.albumImages,
|
||||
message.quotedMessage.albumImagesCount,
|
||||
message.albumId,
|
||||
if len(message.albumId) == 0: @[] else: @[message.image],
|
||||
if len(message.albumId) == 0: @[] else: @[message.id],
|
||||
message.albumImagesCount,
|
||||
message.bridgeMessage,
|
||||
message.quotedMessage.bridgeMessage,
|
||||
message.paymentRequests
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
transactionContract,
|
||||
transactionValue,
|
||||
)
|
||||
|
||||
method delete*(self: Module) =
|
||||
|
@ -865,3 +865,90 @@ QtObject:
|
||||
self.dataChanged(index, index, @[ModelRole.AlbumMessageImages.int])
|
||||
return true
|
||||
return false
|
||||
|
||||
proc createMessageItemFromDtos*(
|
||||
message: MessageDto,
|
||||
communityId: string,
|
||||
sender: ContactDetails,
|
||||
isCurrentUser: bool,
|
||||
renderedMessageText: string,
|
||||
clearText: string,
|
||||
albumImages: seq[string] = @[],
|
||||
albumMessageIds: seq[string] = @[],
|
||||
deletedByContactDetails: ContactDetails = ContactDetails(),
|
||||
quotedMessageAuthorDetails: ContactDetails = ContactDetails(),
|
||||
quotedRenderedMessageText: string = "",
|
||||
transactionContract: string = "",
|
||||
transactionValue: string = "",
|
||||
): Item =
|
||||
var albumImagesFinal = albumImages
|
||||
if albumImagesFinal.len == 0:
|
||||
albumImagesFinal = if (len(message.albumId) == 0): @[] else: @[message.image]
|
||||
|
||||
var albumMessageIdsFinal = albumMessageIds
|
||||
if albumMessageIdsFinal.len == 0:
|
||||
albumMessageIdsFinal = if (len(message.albumId) == 0): @[] else: @[message.id]
|
||||
|
||||
return message_item.initMessageItem(
|
||||
message.id,
|
||||
communityId,
|
||||
message.chatId,
|
||||
message.responseTo,
|
||||
message.`from`,
|
||||
sender.defaultDisplayName,
|
||||
sender.optionalName,
|
||||
sender.icon,
|
||||
sender.colorHash,
|
||||
(isCurrentUser and message.contentType != ContentType.DiscordMessage),
|
||||
sender.dto.added,
|
||||
message.outgoingStatus,
|
||||
renderedMessageText,
|
||||
clearText,
|
||||
message.parsedText,
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
message.seen,
|
||||
timestamp = message.timestamp,
|
||||
clock = message.clock,
|
||||
message.contentType,
|
||||
message.messageType,
|
||||
message.contactRequestState,
|
||||
sticker = message.sticker.url,
|
||||
message.sticker.pack,
|
||||
message.links,
|
||||
message.linkPreviews,
|
||||
newTransactionParametersItem(message.transactionParameters.id,
|
||||
message.transactionParameters.fromAddress,
|
||||
message.transactionParameters.address,
|
||||
transactionContract,
|
||||
transactionValue,
|
||||
message.transactionParameters.transactionHash,
|
||||
message.transactionParameters.commandState,
|
||||
message.transactionParameters.signature),
|
||||
message.mentionedUsersPks(),
|
||||
sender.dto.trustStatus,
|
||||
sender.dto.ensVerified,
|
||||
message.discordMessage,
|
||||
resendError = "",
|
||||
message.deleted,
|
||||
message.deletedBy,
|
||||
deletedByContactDetails,
|
||||
message.pinnedBy,
|
||||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
quotedRenderedMessageText,
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
quotedMessageAuthorDetails,
|
||||
message.quotedMessage.albumImages,
|
||||
message.quotedMessage.albumImagesCount,
|
||||
message.albumId,
|
||||
albumImagesFinal,
|
||||
albumMessageIdsFinal,
|
||||
message.albumImagesCount,
|
||||
message.bridgeMessage,
|
||||
message.quotedMessage.bridgeMessage,
|
||||
message.paymentRequests,
|
||||
)
|
@ -9,61 +9,17 @@ import app/modules/shared_models/message_item
|
||||
import app/modules/shared_models/message_transaction_parameters_item
|
||||
|
||||
proc createTestMessageItem(id: string, clock: int64): Item =
|
||||
return initMessageItem(
|
||||
id = id,
|
||||
return message_model.createMessageItemFromDtos(
|
||||
message = MessageDto(
|
||||
id: id,
|
||||
clock: clock,
|
||||
contentType: ContentType.Unknown,
|
||||
),
|
||||
communityId = "",
|
||||
chatId = "",
|
||||
responseToMessageWithId = "",
|
||||
senderId = "",
|
||||
senderDisplayName = "",
|
||||
senderOptionalName = "",
|
||||
senderIcon = "",
|
||||
senderColorHash = "",
|
||||
amISender = false,
|
||||
senderIsAdded = false,
|
||||
outgoingStatus = "",
|
||||
text = "",
|
||||
unparsedText = "",
|
||||
parsedText = @[],
|
||||
image = "",
|
||||
messageContainsMentions = false,
|
||||
seen = true,
|
||||
timestamp = 0,
|
||||
clock = clock,
|
||||
contentType = ContentType.Unknown,
|
||||
messageType = -1,
|
||||
contactRequestState = 0,
|
||||
sticker = "",
|
||||
stickerPack = -1,
|
||||
links = @[],
|
||||
linkPreviews = @[],
|
||||
transactionParameters = newTransactionParametersItem("","","","","","",-1,""),
|
||||
mentionedUsersPks = @[],
|
||||
senderTrustStatus = TrustStatus.Unknown,
|
||||
senderEnsVerified = false,
|
||||
discordMessage = DiscordMessage(),
|
||||
resendError = "",
|
||||
deleted = false,
|
||||
deletedBy = "",
|
||||
deletedByContactDetails = ContactDetails(),
|
||||
pinnedBy = "",
|
||||
mentioned = false,
|
||||
quotedMessageFrom = "",
|
||||
quotedMessageText = "",
|
||||
quotedMessageParsedText = "",
|
||||
quotedMessageContentType = ContentType.Unknown,
|
||||
quotedMessageDeleted = false,
|
||||
quotedMessageDiscordMessage = DiscordMessage(),
|
||||
quotedMessageAuthorDetails = ContactDetails(),
|
||||
quotedMessageAlbumMessageImages = @[],
|
||||
quotedMessageAlbumImagesCount = 0,
|
||||
albumId = "",
|
||||
albumMessageImages = @[],
|
||||
albumMessageIds = @[],
|
||||
albumImagesCount = 0,
|
||||
bridgeMessage = BridgeMessage(),
|
||||
quotedBridgeMessage = BridgeMessage(),
|
||||
paymentRequests = @[],
|
||||
sender = ContactDetails(),
|
||||
isCurrentUser = false,
|
||||
renderedMessageText = "",
|
||||
clearText = "",
|
||||
)
|
||||
|
||||
let message0_chatIdentifier = createTestMessageItem("chat-identifier", -2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user