chibenwa commented on code in PR #1106:
URL: https://github.com/apache/james-project/pull/1106#discussion_r938604853
##########
third-party/rspamd/src/main/java/org/apache/james/rspamd/RSpamDScanner.java:
##########
@@ -36,25 +36,36 @@
import org.apache.mailet.PerRecipientHeaders;
import org.apache.mailet.base.GenericMailet;
+import com.github.fge.lambdas.Throwing;
import com.google.common.collect.ImmutableList;
public class RSpamDScanner extends GenericMailet {
public static final AttributeName FLAG_MAIL =
AttributeName.of("org.apache.james.rspamd.flag");
public static final AttributeName STATUS_MAIL =
AttributeName.of("org.apache.james.rspamd.status");
private final RSpamDHttpClient rSpamDHttpClient;
+ private boolean rewriteSubject;
@Inject
public RSpamDScanner(RSpamDHttpClient rSpamDHttpClient) {
this.rSpamDHttpClient = rSpamDHttpClient;
}
+ @Override
+ public void init() {
+ rewriteSubject =
getBooleanParameter(getInitParameter("rewriteSubject"), false);
+ }
+
@Override
public void service(Mail mail) throws MessagingException {
AnalysisResult rSpamDResult = rSpamDHttpClient.checkV2(new
MimeMessageInputStream(mail.getMessage())).block();
mail.getRecipients()
.forEach(recipient -> appendRSpamDResultHeader(mail, recipient,
rSpamDResult));
+
+ rSpamDResult.getDesiredRewriteSubject()
+ .filter(any -> rewriteSubject)
+ .ifPresent(Throwing.consumer(desiredRewriteSubject ->
mail.getMessage().setSubject(desiredRewriteSubject)));
Review Comment:
```
if (rewriteSubject) {
rSpamDResult.getDesiredRewriteSubject()
.ifPresent(Throwing.consumer(desiredRewriteSubject ->
mail.getMessage().setSubject(desiredRewriteSubject)));
}
```
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]