You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/SessionMessagingKit/Messages/Signal/TSIncomingMessage+Conversio...

28 lines
1.1 KiB
Swift

public extension TSIncomingMessage {
static func from(_ visibleMessage: VisibleMessage, quotedMessage: TSQuotedMessage?, linkPreview: OWSLinkPreview?, associatedWith thread: TSThread) -> TSIncomingMessage {
let sender = visibleMessage.sender!
var expiration: UInt32 = 0
Storage.read { transaction in
expiration = thread.disappearingMessagesDuration(with: transaction)
}
let result = TSIncomingMessage(
timestamp: visibleMessage.sentTimestamp!,
in: thread,
authorId: sender,
sourceDeviceId: 1,
messageBody: visibleMessage.text,
attachmentIds: visibleMessage.attachmentIDs,
expiresInSeconds: expiration,
quotedMessage: quotedMessage,
linkPreview: linkPreview,
serverTimestamp: nil,
wasReceivedByUD: true
)
result.openGroupServerMessageID = visibleMessage.openGroupServerMessageID ?? 0
result.isOpenGroupMessage = result.openGroupServerMessageID != 0
return result
}
}