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 2020/12/21 07:29:29 UTC

[james-project] 04/17: JAMES-3431 Only include diagnostic code for failed & delayed actions

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 1baa5d2cc55a0da936994d9c25bafda8fe941a2e
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Dec 16 17:45:04 2020 +0700

    JAMES-3431 Only include diagnostic code for failed & delayed actions
---
 .../apache/james/transport/mailets/DSNBounce.java  | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
index 4a620ee..916c736 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
@@ -118,11 +118,11 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
     private static final Logger LOGGER = LoggerFactory.getLogger(DSNBounce.class);
 
     enum Action {
-        DELIVERED("delivered"),
-        DELAYED("delayed"),
-        FAILED("failed"),
-        EXPANDED("expanded"),
-        RELAYED("relayed");
+        DELIVERED("delivered", false),
+        DELAYED("delayed", true),
+        FAILED("failed", true),
+        EXPANDED("expanded", false),
+        RELAYED("relayed", false);
 
         public static Optional<Action> parse(String serialized) {
             return Stream.of(Action.values())
@@ -131,14 +131,20 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
         }
 
         private final String value;
+        private final boolean shouldIncludeDiagnosticCode;
 
-        Action(String value) {
+        Action(String value, boolean shouldIncludeDiagnosticCode) {
             this.value = value;
+            this.shouldIncludeDiagnosticCode = shouldIncludeDiagnosticCode;
         }
 
         public String asString() {
             return value;
         }
+
+        public boolean shouldIncludeDiagnosticCode() {
+            return shouldIncludeDiagnosticCode;
+        }
     }
 
     private static final ImmutableSet<String> CONFIGURABLE_PARAMETERS = ImmutableSet.of("debug", "passThrough", "messageString", "attachment", "sender", "prefix", "action");
@@ -452,7 +458,9 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
         buffer.append("Final-Recipient: rfc822; " + mailAddress.toString()).append(LINE_BREAK);
         buffer.append("Action: ").append(action.asString()).append(LINE_BREAK);
         buffer.append("Status: " + deliveryError).append(LINE_BREAK);
-        buffer.append("Diagnostic-Code: " + getDiagnosticType(deliveryError) + "; " + deliveryError).append(LINE_BREAK);
+        if (action.shouldIncludeDiagnosticCode()) {
+            buffer.append("Diagnostic-Code: " + getDiagnosticType(deliveryError) + "; " + deliveryError).append(LINE_BREAK);
+        }
         buffer.append("Last-Attempt-Date: " + dateFormatter.format(ZonedDateTime.ofInstant(lastUpdated.toInstant(), ZoneId.systemDefault())))
             .append(LINE_BREAK);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org