@Test void headersShouldBeUnfoldedAndDecoded() throws Exception { Keywords keywords = Keywords.strictFactory().from(Keyword.SEEN); String headers = "From: user <user@domain>\n" + "Subject: test subject\n" + "To: user1 <user1@domain>,\r\n" + " user2 <user2@domain>\n" + "Cc: =?UTF-8?Q?Beno=c3=aet_TELLIER?= <tellier@linagora.com>"; MetaDataWithContent testMail = MetaDataWithContent.builder() .uid(MessageUid.of(2)) .keywords(keywords) .size(headers.length()) .internalDate(INTERNAL_DATE) .content(new ByteArrayInputStream(headers.getBytes(StandardCharsets.UTF_8))) .attachments(ImmutableList.of()) .mailboxId(MAILBOX_ID) .messageId(TestMessageId.of(2)) .build(); Emailer user = Emailer.builder().name("user").email("user@domain").build(); Emailer user1 = Emailer.builder().name("user1").email("user1@domain").build(); Emailer user2 = Emailer.builder().name("user2").email("user2@domain").build(); Emailer usercc = Emailer.builder().name("Benoît TELLIER").email("tellier@linagora.com").build(); ImmutableMap<String, String> headersMap = ImmutableMap.<String, String>builder() .put("Cc", "Benoît TELLIER <tellier@linagora.com>") .put("Subject", "test subject") .put("From", "user <user@domain>") .put("To", "user1 <user1@domain>, user2 <user2@domain>") .put("MIME-Version", "1.0") .build(); MessageFullView testee = messageFullViewFactory.fromMetaDataWithContent(testMail).block(); MessageFullView expected = MessageFullView.builder() .id(TestMessageId.of(2)) .blobId(BlobId.of("2")) .threadId("2") .mailboxId(MAILBOX_ID) .headers(headersMap) .from(user) .to(ImmutableList.of(user1, user2)) .cc(ImmutableList.of(usercc)) .subject("test subject") .date(Instant.parse("2012-02-03T14:30:42.000Z")) .size(headers.length()) .preview(Preview.from("(Empty)")) .textBody(Optional.of("")) .htmlBody(Optional.empty()) .keywords(keywords) .hasAttachment(false) .build(); assertThat(testee).isEqualToComparingFieldByField(expected); }
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);  }