diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt index 92c1620..df696ad 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt @@ -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 diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt index c37e84b..5ea099e 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt @@ -6,15 +6,15 @@ import java.time.ZoneId class Email( val sender: EmailAddress?, val subject: String, + val date: Instant, val to: List, val cc: List, - 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 + val plainTextBody: String? = null, + val htmlBody: String? = null, + val attachments: List = emptyList() ) { val plainTextOrHtmlBody: String? by lazy { plainTextBody ?: htmlBody }