Moved date up and added default values

This commit is contained in:
dankito 2024-11-27 04:23:07 +01:00
parent 318903db40
commit 00c062f9a9
2 changed files with 7 additions and 7 deletions

View File

@ -157,10 +157,10 @@ open class EmailsFetcher(
val sender = message.from?.firstOrNull()?.let { map(it) }
val email = Email(
sender, message.subject ?: "",
sender, message.subject ?: "", map(message.sentDate ?: message.receivedDate),
message.getRecipients(Message.RecipientType.TO).map { map(it) }, message.getRecipients(Message.RecipientType.CC).map { map(it) },
(message.replyTo.firstOrNull() as? InternetAddress)?.let { if (it.address != sender?.address) map(it) else null }, // only set replyTo if it differs from sender
map(message.sentDate ?: message.receivedDate), status.folder.getUID(message),
status.folder.getUID(message),
parts.any { it.mediaType == "application/pgp-encrypted" },
getPlainTextBody(messageBodyParts, status), getHtmlBody(messageBodyParts, status),
attachments

View File

@ -6,15 +6,15 @@ import java.time.ZoneId
class Email(
val sender: EmailAddress?,
val subject: String,
val date: Instant,
val to: List<EmailAddress>,
val cc: List<EmailAddress>,
val replayTo: EmailAddress?,
val date: Instant,
val replayTo: EmailAddress? = null,
val messageId: Long,
val isEncrypted: Boolean = false,
val plainTextBody: String?,
val htmlBody: String?,
val attachments: List<EmailAttachment>
val plainTextBody: String? = null,
val htmlBody: String? = null,
val attachments: List<EmailAttachment> = emptyList()
) {
val plainTextOrHtmlBody: String? by lazy { plainTextBody ?: htmlBody }