You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/05/14 06:42:47 UTC
[james-project] 15/15: JAMES-1965 MessageFullViewFactory: Avoid
performing HTML text extraction if not needed
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 1554adbf5e0926e40c147d57042b582c90ec240c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon May 10 13:23:59 2021 +0700
JAMES-1965 MessageFullViewFactory: Avoid performing HTML text extraction if not needed
---
.../jmap/draft/model/message/view/MessageFullViewFactory.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFullViewFactory.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFullViewFactory.java
index d391e03..73ca18b 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFullViewFactory.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFullViewFactory.java
@@ -102,8 +102,7 @@ public class MessageFullViewFactory implements MessageViewFactory<MessageFullVie
private Mono<MessageFullView> fromMetaDataWithContent(MetaDataWithContent message, Message mimeMessage) throws IOException {
MessageContent messageContent = messageContentExtractor.extract(mimeMessage);
Optional<String> htmlBody = messageContent.getHtmlBody();
- Optional<String> mainTextContent = messageContent.extractMainTextContent(htmlTextExtractor);
- Optional<String> textBody = computeTextBodyIfNeeded(messageContent, mainTextContent);
+ Optional<String> textBody = computeTextBodyIfNeeded(messageContent);
return retrieveProjection(messageContent, message.getMessageId(),
() -> MessageFullView.hasAttachment(getAttachments(message.getAttachments())))
@@ -196,10 +195,9 @@ public class MessageFullViewFactory implements MessageViewFactory<MessageFullVie
.build();
}
- private Optional<String> computeTextBodyIfNeeded(MessageContent messageContent, Optional<String> mainTextContent) {
+ private Optional<String> computeTextBodyIfNeeded(MessageContent messageContent) {
return messageContent.getTextBody()
- .map(Optional::of)
- .orElse(mainTextContent);
+ .or(() -> messageContent.extractMainTextContent(htmlTextExtractor));
}
private Optional<String> mainTextContent(MessageContent messageContent) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org