You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/11/24 01:43:41 UTC

[james-project] 05/08: JAMES-3534 Identity/set create should record succeeded creation ids within the processing context

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 231604f3913eb8ac2eeb32b356527c00dc0ea1b9
Author: Quan Tran <hq...@linagora.com>
AuthorDate: Mon Nov 22 15:13:42 2021 +0700

    JAMES-3534 Identity/set create should record succeeded creation ids within the processing context
---
 .../main/scala/org/apache/james/jmap/api/model/Identity.scala  |  4 +++-
 .../scala/org/apache/james/jmap/method/IdentitySetMethod.scala | 10 ++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/server/data/data-jmap/src/main/scala/org/apache/james/jmap/api/model/Identity.scala b/server/data/data-jmap/src/main/scala/org/apache/james/jmap/api/model/Identity.scala
index 58a9cc1..d57bf24 100644
--- a/server/data/data-jmap/src/main/scala/org/apache/james/jmap/api/model/Identity.scala
+++ b/server/data/data-jmap/src/main/scala/org/apache/james/jmap/api/model/Identity.scala
@@ -40,7 +40,9 @@ case class MayDeleteIdentity(value: Boolean) extends AnyVal
 object IdentityId {
   def generate: IdentityId = IdentityId(UUID.randomUUID())
 }
-case class IdentityId(id: UUID)
+case class IdentityId(id: UUID) {
+  def serialize: String = id.toString
+}
 
 case class Identity(id: IdentityId,
                     name: IdentityName,
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetMethod.scala
index 6138f2a..c68fc83 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetMethod.scala
@@ -23,7 +23,7 @@ import eu.timepit.refined.auto._
 import javax.inject.Inject
 import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, EMAIL_SUBMISSION, JMAP_CORE}
 import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
-import org.apache.james.jmap.core.{Invocation, UuidState}
+import org.apache.james.jmap.core.{ClientId, Id, Invocation, ServerId, UuidState}
 import org.apache.james.jmap.json.{IdentitySerializer, ResponseSerializer}
 import org.apache.james.jmap.mail.{IdentitySetRequest, IdentitySetResponse}
 import org.apache.james.jmap.routes.SessionSupplier
@@ -57,5 +57,11 @@ class IdentitySetMethod @Inject()(createPerformer: IdentitySetCreatePerformer,
           created = creationResults.created.filter(_.nonEmpty),
           notCreated = creationResults.notCreated.filter(_.nonEmpty)))),
         methodCallId = invocation.invocation.methodCallId),
-      processingContext = invocation.processingContext)
+      processingContext = creationResults.created.getOrElse(Map())
+        .foldLeft(invocation.processingContext)({
+          case (processingContext, (clientId, response)) =>
+            Id.validate(response.id.serialize)
+              .fold(_ => processingContext,
+                serverId => processingContext.recordCreatedId(ClientId(clientId.id), ServerId(serverId)))
+        }))
 }

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