From 0a53966b167cf6957ca69b22480fc361e59a80fd Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 28 Nov 2024 01:50:52 +0100 Subject: [PATCH] Up prioritized messageId and added documentation for it --- .../net/codinux/invoicing/email/EmailsFetcher.kt | 2 +- .../net/codinux/invoicing/email/model/Email.kt | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) 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 c2c7cfb..acdfe83 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 plainTextBody = getPlainTextBody(messageBodyParts, status) val email = Email( + status.folder.getUID(message), sender, message.subject ?: "", map(message.sentDate ?: message.receivedDate), message.getRecipients(Message.RecipientType.TO).orEmpty().map { map(it) }, message.getRecipients(Message.RecipientType.CC).orEmpty().map { map(it) }, message.getRecipients(Message.RecipientType.BCC).orEmpty().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 - status.folder.getUID(message), parts.any { it.mediaType == "application/pgp-encrypted" }, imapMessage?.contentLanguage?.firstOrNull(), plainTextBody, getHtmlBody(messageBodyParts, status, plainTextBody), 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 ba6740a..3295134 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 @@ -4,18 +4,31 @@ import java.time.Instant import java.time.ZoneId class Email( + /** + * Unique identifier of the message, used as identifier to retrieve further data of this message or as identifier + * of the last downloaded message (to continue fetching emails at messages newer than the message with this id). + * + * Actually the IMAP UID, but the user should not care which ID this value refers to. + * (messageUID: Unique identifier of a message in an email account. Survives e.g. expunging and moving the message to a different folder. This value. + * messageNumber: Non stable number. Message numbers e.g. change on expunge. + * messageId: Long string that is reference in inReplyTo field to identify to which message this message is a response of. Not of interest for us. + */ + val messageId: Long, + val sender: EmailAddress?, val subject: String, val date: Instant, + val to: List, val cc: List = emptyList(), val bcc: List = emptyList(), val replayTo: EmailAddress? = null, - val messageId: Long, + val isEncrypted: Boolean = false, val contentLanguage: String? = null, val plainTextBody: String? = null, val htmlBody: String? = null, + val attachments: List = emptyList() ) { val plainTextOrHtmlBody: String? by lazy { plainTextBody ?: htmlBody }