chibenwa commented on code in PR #1758:
URL: https://github.com/apache/james-project/pull/1758#discussion_r1365853070


##########
server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/mailet/filter/ActionApplier.java:
##########
@@ -182,4 +201,32 @@ private void sendACopy(MailetContext context, MailAddress 
originalRecipient, Lis
             LifecycleUtil.dispose(copy);
         }
     }
+
+    private Attribute createAttribute(List<MailAddress> forwards) {
+        return new 
Attribute(AttributeName.FORWARDED_MAIL_ADDRESSES_ATTRIBUTE_NAME,
+            AttributeValue.of(forwards.stream().map(mailAddress -> 
AttributeValue.of(mailAddress.asString())).collect(ImmutableList.toImmutableList())));
+    }
+
+    private Attribute createAttribute(Set<MailAddress> forwardedMailAddresses, 
List<MailAddress> newForwards) {
+        return new 
Attribute(AttributeName.FORWARDED_MAIL_ADDRESSES_ATTRIBUTE_NAME,
+            AttributeValue.of(Stream.concat(forwardedMailAddresses.stream(), 
newForwards.stream())
+                .map(mailAddress -> AttributeValue.of(mailAddress.asString()))
+                .collect(ImmutableList.toImmutableList())));
+    }
+
+    private List<MailAddress> getNewForwards(List<MailAddress> forwards, 
Set<MailAddress> forwardedMailAddresses) {
+        List<MailAddress> newForwards = forwards.stream()
+            .filter(mailAddress -> 
!forwardedMailAddresses.contains(mailAddress))
+            .collect(ImmutableList.toImmutableList());
+        return newForwards;
+    }
+
+    private Set<MailAddress> getForwardedMailAddresses(Optional<Attribute> 
attribute) {
+        Collection<AttributeValue> attributeValues = 
(Collection<AttributeValue>) attribute.get().getValue().getValue();
+        Set<MailAddress> forwardedMailAddresses = attributeValues
+            .stream()
+            .map(Throwing.function(attributeValue -> new MailAddress((String) 
attributeValue.getValue())))
+            .collect(ImmutableSet.toImmutableSet());
+        return forwardedMailAddresses;
+    }

Review Comment:
   Any solution to not duplicate that code?



-- 
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: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to