Fixed that sent date may is null

This commit is contained in:
dankito 2024-11-21 18:40:13 +01:00
parent 189b1b37ff
commit 2516328da8
2 changed files with 3 additions and 3 deletions

View File

@ -103,7 +103,7 @@ class MailReader(
if (attachmentsWithEInvoice.isNotEmpty()) { if (attachmentsWithEInvoice.isNotEmpty()) {
return@mapNotNull MailWithInvoice( return@mapNotNull MailWithInvoice(
message.from.joinToString(), message.subject, message.from.joinToString(), message.subject,
map(message.sentDate), map(message.receivedDate), message.messageNumber, message.sentDate?.let { map(it) }, map(message.receivedDate), message.messageNumber,
attachmentsWithEInvoice attachmentsWithEInvoice
) )
} }

View File

@ -6,10 +6,10 @@ import java.time.ZoneId
class MailWithInvoice( class MailWithInvoice(
val sender: String, val sender: String,
val subject: String, val subject: String,
val sent: Instant, val sent: Instant?,
val received: Instant, val received: Instant,
val messageNumber: Int, val messageNumber: Int,
val attachmentsWithEInvoice: List<MailAttachmentWithEInvoice> val attachmentsWithEInvoice: List<MailAttachmentWithEInvoice>
) { ) {
override fun toString() = "${sent.atZone(ZoneId.systemDefault()).toLocalDate()} $sender: $subject, ${attachmentsWithEInvoice.size} invoice(s)" override fun toString() = "${(sent ?: received).atZone(ZoneId.systemDefault()).toLocalDate()} $sender: $subject, ${attachmentsWithEInvoice.size} invoice(s)"
} }