chibenwa commented on a change in pull request #356:
URL: https://github.com/apache/james-project/pull/356#discussion_r606189466
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSubmissionSet.scala
##########
@@ -63,6 +64,33 @@ case class EmailSubmissionSetRequest(accountId: AccountId,
create = None,
update = None,
destroy = onSuccessDestroyEmail)))
+
+ def validate: Either[IllegalArgumentException, EmailSubmissionSetRequest] = {
+ val supportedCreationIds: List[EmailSubmissionCreationId] =
create.getOrElse(Map()).keys.toList
+
+ onSuccessUpdateEmail.getOrElse(Map())
+ .keys
+ .toList
+ .map(id => validate(id, supportedCreationIds))
+ .sequence
+ .map(_ => this)
+ }
+
+ private def validate(creationId: EmailSubmissionCreationId,
supportedCreationIds: List[EmailSubmissionCreationId]):
Either[IllegalArgumentException, EmailSubmissionCreationId] = {
+ if (creationId.startsWith("#")) {
+ val realId = creationId.substring(1)
+ val validatedId: Either[String, EmailSubmissionCreationId] =
refineV[IdConstraint](realId)
+ validatedId
+ .left.map(s => new IllegalArgumentException(s))
Review comment:
Yes, as we need to transform `Either[String, X]` into
`Either[IllegalArgumentException, X]`
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]