Up prioritized messageId and added documentation for it

This commit is contained in:
dankito 2024-11-28 01:50:52 +01:00
parent 110da9ced6
commit 0a53966b16
2 changed files with 15 additions and 2 deletions

View File

@ -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),

View File

@ -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<EmailAddress>,
val cc: List<EmailAddress> = emptyList(),
val bcc: List<EmailAddress> = 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<EmailAttachment> = emptyList()
) {
val plainTextOrHtmlBody: String? by lazy { plainTextBody ?: htmlBody }