Mapping sent to Instant; also mapping received and messageNumber
This commit is contained in:
parent
07fdbec5d7
commit
b09b7cf69b
|
@ -15,8 +15,7 @@ import net.codinux.invoicing.reader.EInvoiceReader
|
|||
import net.codinux.log.logger
|
||||
import org.eclipse.angus.mail.imap.IMAPFolder
|
||||
import java.io.File
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
|
@ -101,7 +100,11 @@ class MailReader(
|
|||
}
|
||||
|
||||
if (attachmentsWithEInvoice.isNotEmpty()) {
|
||||
return@mapNotNull MailWithInvoice(message.from.joinToString(), message.subject, map(message.sentDate), attachmentsWithEInvoice)
|
||||
return@mapNotNull MailWithInvoice(
|
||||
message.from.joinToString(), message.subject,
|
||||
map(message.sentDate), map(message.receivedDate), message.messageNumber,
|
||||
attachmentsWithEInvoice
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
|
@ -153,9 +156,8 @@ class MailReader(
|
|||
null
|
||||
}
|
||||
|
||||
// TODO: same code as in MustangMapper
|
||||
private fun map(date: Date): LocalDate =
|
||||
date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()
|
||||
private fun map(date: Date): Instant =
|
||||
date.toInstant()
|
||||
|
||||
|
||||
private fun <T> connect(account: MailAccount, connected: (Store) -> T?): T? {
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package net.codinux.invoicing.mail
|
||||
|
||||
import java.time.LocalDate
|
||||
import java.time.Instant
|
||||
import java.time.ZoneId
|
||||
|
||||
class MailWithInvoice(
|
||||
val sender: String,
|
||||
val subject: String,
|
||||
val date: LocalDate,
|
||||
val sent: Instant,
|
||||
val received: Instant,
|
||||
val messageNumber: Int,
|
||||
val attachmentsWithEInvoice: List<MailAttachmentWithEInvoice>
|
||||
) {
|
||||
override fun toString() = "$date $sender: $subject, ${attachmentsWithEInvoice.size} invoices"
|
||||
override fun toString() = "${sent.atZone(ZoneId.systemDefault()).toLocalDate()} $sender: $subject, ${attachmentsWithEInvoice.size} invoice(s)"
|
||||
}
|
Loading…
Reference in New Issue