@Test void textBodyShouldNotOverrideWhenItIsThere() throws Exception { ByteArrayInputStream messageContent = new ByteArrayInputStream(("Subject\n" + "MIME-Version: 1.0\n" + "Content-Type: multipart/alternative;\n" + "\tboundary=\"----=_Part_370449_1340169331.1489506420401\"\n" + "\n" + "------=_Part_370449_1340169331.1489506420401\n" + "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 7bit\n" + "\n" + "My plain message\n" + "------=_Part_370449_1340169331.1489506420401\n" + "Content-Type: text/html; charset=UTF-8\n" + "Content-Transfer-Encoding: 7bit\n" + "\n" + "<a>The </a> <strong>HTML</strong> message" ).getBytes(StandardCharsets.UTF_8)); MetaDataWithContent testMail = MetaDataWithContent.builder() .uid(MessageUid.of(2)) .keywords(Keywords.strictFactory().from(Keyword.SEEN)) .internalDate(INTERNAL_DATE) .size(1000) .content(messageContent) .attachments(ImmutableList.of()) .mailboxId(MAILBOX_ID) .messageId(TestMessageId.of(2)) .build(); MessageFullView testee = messageFullViewFactory.fromMetaDataWithContent(testMail).block(); assertThat(testee.getTextBody()) .isPresent() .isEqualTo(Optional.of("My plain message")); }
public Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message) { return Mono.fromCallable(() -> Helpers.parse(message.getContent())) .flatMap(Throwing.function(mimeMessage -> fromMetaDataWithContent(message, mimeMessage))); }
MessageFullViewFactory implements MessageViewFactory<MessageFullView> { public Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message) { return Mono.fromCallable(() -> Helpers.parse(message.getContent())) .flatMap(Throwing.function(mimeMessage -> fromMetaDataWithContent(message, mimeMessage))); } }
MessageFullViewFactory implements MessageViewFactory<MessageFullView> { public Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message) { return Mono.fromCallable(() -> Helpers.parse(message.getContent())) .flatMap(Throwing.function(mimeMessage -> fromMetaDataWithContent(message, mimeMessage))); } @Inject  MessageFullViewFactory(BlobManager blobManager, MessageContentExtractor messageContentExtractor,
                                  HtmlTextExtractor htmlTextExtractor, MessageIdManager messageIdManager,
                                  MessageFastViewProjection fastViewProjection); }
MessageFullViewFactory implements MessageViewFactory<MessageFullView> { public Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message) { return Mono.fromCallable(() -> Helpers.parse(message.getContent())) .flatMap(Throwing.function(mimeMessage -> fromMetaDataWithContent(message, mimeMessage))); } @Inject  MessageFullViewFactory(BlobManager blobManager, MessageContentExtractor messageContentExtractor,
                                  HtmlTextExtractor htmlTextExtractor, MessageIdManager messageIdManager,
                                  MessageFastViewProjection fastViewProjection); @Override Flux<MessageFullView> fromMessageIds(List<MessageId> messageIds, MailboxSession mailboxSession); Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message); }
MessageFullViewFactory implements MessageViewFactory<MessageFullView> { public Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message) { return Mono.fromCallable(() -> Helpers.parse(message.getContent())) .flatMap(Throwing.function(mimeMessage -> fromMetaDataWithContent(message, mimeMessage))); } @Inject  MessageFullViewFactory(BlobManager blobManager, MessageContentExtractor messageContentExtractor,
                                  HtmlTextExtractor htmlTextExtractor, MessageIdManager messageIdManager,
                                  MessageFastViewProjection fastViewProjection); @Override Flux<MessageFullView> fromMessageIds(List<MessageId> messageIds, MailboxSession mailboxSession); Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message);  }