vttranlina commented on code in PR #2040:
URL: https://github.com/apache/james-project/pull/2040#discussion_r1510547524


##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala:
##########
@@ -337,6 +338,24 @@ class EmailSubmissionSetMethod @Inject()(serializer: 
EmailSubmissionSetSerialize
       Failure(new IllegalArgumentException("Invalid delayed time!"))
     }
 
+  def validateMimeMessages(mimeMessage: MimeMessage) : SMono[MimeMessage] = 
validateMailAddressHeaderMimeMessage(mimeMessage)
+  private def validateMailAddressHeaderMimeMessage(mimeMessage: MimeMessage): 
SMono[MimeMessage] =
+    SFlux.fromIterable(Map("to" -> 
Option(mimeMessage.getRecipients(RecipientType.TO)).toList.flatten,
+        "cc" -> 
Option(mimeMessage.getRecipients(RecipientType.CC)).toList.flatten,
+        "bcc" -> 
Option(mimeMessage.getRecipients(RecipientType.BCC)).toList.flatten,
+        "from" -> Option(mimeMessage.getFrom).toList.flatten,
+        "sender" -> Option(mimeMessage.getSender).toList,
+        "replyTo" -> Option(mimeMessage.getReplyTo).toList.flatten))
+      .doOnNext { case (headerName, addresses) => (headerName, 
addresses.foreach(address => validateMailAddress(headerName, address))) }
+      .`then`()
+      .`then`(SMono.just(mimeMessage))
+
+  private def validateMailAddress(headName: String, address: Address): 
MailAddress =
+    Try(new MailAddress(address.toString)) match {

Review Comment:
   class `Address` do not have `.getAddress` method



-- 
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