@Test void headersShouldBeSetIntoMessage() throws Exception { Keywords keywords = Keywords.strictFactory().from(Keyword.SEEN); String headers = "From: user <user@domain>\n" + "Subject: test subject\n" + "To: user1 <user1@domain>, user2 <user2@domain>\n" + "Cc: usercc <usercc@domain>\n" + "Bcc: userbcc <userbcc@domain>\n" + "Reply-To: \"user to reply to\" <user.reply.to@domain>\n" + "In-Reply-To: <SNT124-W2664003139C1E520CF4F6787D30@phx.gbl>\n" + "Date: Tue, 14 Jul 2015 12:30:42 +0000\n" + "Other-header: other header value"; 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("usercc").email("usercc@domain").build(); Emailer userbcc = Emailer.builder().name("userbcc").email("userbcc@domain").build(); Emailer userRT = Emailer.builder().name("user to reply to").email("user.reply.to@domain").build(); ImmutableMap<String, String> headersMap = ImmutableMap.<String, String>builder() .put("Cc", "usercc <usercc@domain>") .put("Bcc", "userbcc <userbcc@domain>") .put("Subject", "test subject") .put("From", "user <user@domain>") .put("To", "user1 <user1@domain>, user2 <user2@domain>") .put("Reply-To", "\"user to reply to\" <user.reply.to@domain>") .put("In-Reply-To", "<SNT124-W2664003139C1E520CF4F6787D30@phx.gbl>") .put("Other-header", "other header value") .put("Date", "Tue, 14 Jul 2015 12:30:42 +0000") .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) .inReplyToMessageId("<SNT124-W2664003139C1E520CF4F6787D30@phx.gbl>") .headers(headersMap) .from(user) .to(ImmutableList.of(user1, user2)) .cc(ImmutableList.of(usercc)) .bcc(ImmutableList.of(userbcc)) .replyTo(ImmutableList.of(userRT)) .subject("test subject") .date(Instant.parse("2015-07-14T12: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);  }