chibenwa commented on code in PR #1561:
URL: https://github.com/apache/james-project/pull/1561#discussion_r1233326098
##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala:
##########
@@ -319,23 +365,23 @@ class EmailSubmissionSetMethod @Inject()(serializer:
EmailSubmissionSetSerialize
val cc: List[Address] =
Option(mimeMessage.getRecipients(RecipientType.CC)).toList.flatten
val bcc: List[Address] =
Option(mimeMessage.getRecipients(RecipientType.BCC)).toList.flatten
for {
- mailFrom <- Option(mimeMessage.getFrom).toList.flatten
+ mailFrom <- Try(Option(mimeMessage.getFrom).toList.flatten
.headOption
.map(_.asInstanceOf[InternetAddress].getAddress)
.map(s => Try(new MailAddress(s)))
.getOrElse(Failure(new IllegalArgumentException("Implicit envelope
detection requires a from field")))
- .map(EmailSubmissionAddress)
- rcptTo <- (to ++ cc ++ bcc)
+ .get).map(EmailSubmissionAddress(_))
Review Comment:
What is this `.get` for?
Smells like cheating.
To sort your head of `Try[Option[Try[X]]]` use sequence to invert the inner
option and Try then flatmap to merge them, and not actually break functional
programming rules.
--
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]