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 fedf72894f1c438a213d8d94ed887c4fe09c1d2c Author: Tran Tien Duc <[email protected]> AuthorDate: Mon Nov 4 09:53:20 2019 +0700 JAMES-2957 Tail recursive refactoring "extracting message body" --- .../apache/james/transport/matchers/dlp/DlpDomainRules.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/dlp/DlpDomainRules.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/dlp/DlpDomainRules.java index 3fbf59a..9f44886 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/dlp/DlpDomainRules.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/dlp/DlpDomainRules.java @@ -106,16 +106,22 @@ public class DlpDomainRules { if (content instanceof String) { return Stream.of((String) content); } + + return extractContentsComplexType(content) + .flatMap(Throwing.function(this::getMessageBodiesFromContent).sneakyThrow()); + } + + private Stream<Object> extractContentsComplexType(Object content) throws IOException, MessagingException { if (content instanceof Message) { Message message = (Message) content; - return getMessageBodiesFromContent(message.getContent()); + return Stream.of(message.getContent()); } if (content instanceof Multipart) { return MultipartUtil.retrieveBodyParts((Multipart) content) .stream() - .map(Throwing.function(BodyPart::getContent).sneakyThrow()) - .flatMap(Throwing.function(this::getMessageBodiesFromContent).sneakyThrow()); + .map(Throwing.function(BodyPart::getContent).sneakyThrow()); } + return Stream.of(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
