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 2020/12/18 07:27:34 UTC

[james-project] 06/13: JAMES-3463 Remove LTT.RS trick upon Mailbox/changes

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 8f581e95450d75bd58754d5de08f0956871d10d3
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Dec 15 12:39:58 2020 +0700

    JAMES-3463 Remove LTT.RS trick upon Mailbox/changes
    
    Mailbox/get now returns a state that can be piped to
    Mailbox/changes
---
 .../james/jmap/method/MailboxChangesMethod.scala   | 47 +++++++---------------
 1 file changed, 14 insertions(+), 33 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxChangesMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxChangesMethod.scala
index 438704e..8daac10 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxChangesMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxChangesMethod.scala
@@ -46,41 +46,22 @@ class MailboxChangesMethod @Inject()(mailboxSerializer: MailboxSerializer,
   override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_MAIL)
 
   override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: MailboxChangesRequest): SMono[InvocationWithContext] =
-
-    // Support for LTT.RS. This should be removed as soon as Mailbox/get returns the correct state
-    if (request.sinceState.equals(State.INSTANCE)) {
-      val response: MailboxChangesResponse = MailboxChangesResponse(
+    SMono.fromPublisher(mailboxChangeRepository.getSinceState(JavaAccountId.fromUsername(mailboxSession.getUser), JavaState.of(request.sinceState.value), request.maxChanged.toJava))
+      .map(mailboxChanges => MailboxChangesResponse(
         accountId = request.accountId,
-        oldState = State.INSTANCE,
-        newState = State.INSTANCE,
-        hasMoreChanges = HasMoreChanges(false),
+        oldState = request.sinceState,
+        newState = State.fromMailboxChanges(mailboxChanges),
+        hasMoreChanges = HasMoreChanges.fromMailboxChanges(mailboxChanges),
         updatedProperties = Some(Properties()),
-        created = Set(),
-        updated = Set(),
-        destroyed = Set())
-      SMono.just(InvocationWithContext(invocation = Invocation(
-        methodName = methodName,
-        arguments = Arguments(mailboxSerializer.serializeChanges(response)),
-        methodCallId = invocation.invocation.methodCallId
-      ), processingContext = invocation.processingContext))
-    } else {
-      SMono.fromPublisher(mailboxChangeRepository.getSinceState(JavaAccountId.fromUsername(mailboxSession.getUser), JavaState.of(request.sinceState.value), request.maxChanged.toJava))
-        .map(mailboxChanges => MailboxChangesResponse(
-          accountId = request.accountId,
-          oldState = request.sinceState,
-          newState = State.fromMailboxChanges(mailboxChanges),
-          hasMoreChanges = HasMoreChanges.fromMailboxChanges(mailboxChanges),
-          updatedProperties = Some(Properties()),
-          created = mailboxChanges.getCreated.asScala.toSet,
-          updated = mailboxChanges.getUpdated.asScala.toSet,
-          destroyed = mailboxChanges.getDestroyed.asScala.toSet))
-        .map(response => InvocationWithContext(
-          invocation = Invocation(
-            methodName = methodName,
-            arguments = Arguments(mailboxSerializer.serializeChanges(response)),
-            methodCallId = invocation.invocation.methodCallId),
-          processingContext = invocation.processingContext))
-    }
+        created = mailboxChanges.getCreated.asScala.toSet,
+        updated = mailboxChanges.getUpdated.asScala.toSet,
+        destroyed = mailboxChanges.getDestroyed.asScala.toSet))
+      .map(response => InvocationWithContext(
+        invocation = Invocation(
+          methodName = methodName,
+          arguments = Arguments(mailboxSerializer.serializeChanges(response)),
+          methodCallId = invocation.invocation.methodCallId),
+        processingContext = invocation.processingContext))
 
   override def getRequest(mailboxSession: MailboxSession, invocation: Invocation): Either[IllegalArgumentException, MailboxChangesRequest] =
     mailboxSerializer.deserializeMailboxChangesRequest(invocation.arguments.value) match {


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