From a2d34e217f4a292d98132e4acc4df4dec1a5ffd9 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 21 Nov 2024 21:48:24 +0100 Subject: [PATCH] Moved getAllMessageParts() to end --- .../net/codinux/invoicing/mail/MailReader.kt | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt index 8f44d55..f76acc7 100644 --- a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt +++ b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt @@ -8,7 +8,6 @@ import jakarta.mail.Session import jakarta.mail.Store import jakarta.mail.event.MessageCountAdapter import jakarta.mail.event.MessageCountEvent -import jakarta.mail.internet.MimeMultipart import kotlinx.coroutines.* import net.codinux.invoicing.model.Invoice import net.codinux.invoicing.reader.EInvoiceReader @@ -123,25 +122,6 @@ class MailReader( return null } - private fun getAllMessageParts(part: Part): List { - return if (part.isMimeType("multipart/*")) { - val multipart = part.content as Multipart - val parts = IntRange(0, multipart.count - 1).map { multipart.getBodyPart(it) } - - parts.flatMap { subPart -> - getAllMessageParts(subPart) - } - } else { - val mediaType = getMediaType(part) - if (mediaType == null) { - log.warn { "Could not determine media type of message part $part" } - emptyList() - } else { - listOf(MessagePart(mediaType, part)) - } - } - } - private fun findEInvoice(messagePart: MessagePart): MailAttachmentWithEInvoice? { try { val part = messagePart.part @@ -178,6 +158,26 @@ class MailReader( null } + + private fun getAllMessageParts(part: Part): List { + return if (part.isMimeType("multipart/*")) { + val multipart = part.content as Multipart + val parts = IntRange(0, multipart.count - 1).map { multipart.getBodyPart(it) } + + parts.flatMap { subPart -> + getAllMessageParts(subPart) + } + } else { + val mediaType = getMediaType(part) + if (mediaType == null) { + log.warn { "Could not determine media type of message part $part" } + emptyList() + } else { + listOf(MessagePart(mediaType, part)) + } + } + } + /** * In most cases parameters are added to content-type's media type, e.g. * - text/html; charset=utf-8