You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/05/04 11:05:20 UTC

[GitHub] [james-project] LanKhuat commented on a change in pull request #413: JAMES-3575 End to end reactive chain for Email update and JMAP RFC-8621

LanKhuat commented on a change in pull request #413:
URL: https://github.com/apache/james-project/pull/413#discussion_r625691429



##########
File path: server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
##########
@@ -199,30 +199,38 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize
   private def create(request: EmailSubmissionSetRequest,
                      session: MailboxSession,
                      processingContext: ProcessingContext): SMono[(CreationResults, ProcessingContext)] =
-    SFlux.fromIterable(request.create
-      .getOrElse(Map.empty)
-      .view)
-      .fold((CreationResults(Nil), processingContext)) {
-        (acc : (CreationResults, ProcessingContext), elem: (EmailSubmissionCreationId, JsObject)) => {
+    SFlux.fromIterable(
+      request.create
+        .getOrElse(Map.empty)
+        .view)
+      .fold[SMono[(CreationResults, ProcessingContext)]](SMono.just((CreationResults(Nil), processingContext))) {
+        (acc: SMono[(CreationResults, ProcessingContext)], elem: (EmailSubmissionCreationId, JsObject)) => {
           val (emailSubmissionCreationId, jsObject) = elem
-          val (creationResult, updatedProcessingContext) = createSubmission(session, emailSubmissionCreationId, jsObject, acc._2)
-          (CreationResults(acc._1.created :+ creationResult), updatedProcessingContext)
+          acc.flatMap {
+            case (creationResults, processingContext) =>
+              createSubmission(session, emailSubmissionCreationId, jsObject, processingContext)
+                .map {
+                  case (created, updatedProcessingContext) => CreationResults(creationResults.created :+ created) -> updatedProcessingContext
+                }
+              .switchIfEmpty(SMono.error(new RuntimeException("I should not be empty")))
+          }.cache()
         }
       }
+      .flatMap(x => x)

Review comment:
       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:
users@infra.apache.org



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