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/10/19 04:06:43 UTC

[james-project] branch master updated (ebf10df -> 869b197)

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

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


    from ebf10df  JAMES-3662 Accept CORS headers without the JMAP API restriction on "Accept" headers (#699)
     new 3313e41  JAMES-3516 Small Scala code style enhancements to Thread/get
     new 869b197  JAMES-3516 Fix Thread/get error management

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/james/jmap/method/ThreadGetMethod.scala    | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

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


[james-project] 01/02: JAMES-3516 Small Scala code style enhancements to Thread/get

Posted by bt...@apache.org.
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 3313e41ea22a5a98eed9427ae88d63256b9e8070
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Oct 18 21:35:56 2021 +0700

    JAMES-3516 Small Scala code style enhancements to Thread/get
    
     - Remove unneeded blocks
     - Use `_` instead of lambdas
---
 .../scala/org/apache/james/jmap/method/ThreadGetMethod.scala     | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
index 7b91276..8496d9f 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
@@ -66,7 +66,7 @@ class ThreadGetMethod @Inject()(val metricFactory: MetricFactory,
   override val methodName: MethodName = MethodName("Thread/get")
   override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
 
-  override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: ThreadGetRequest): SMono[InvocationWithContext] = {
+  override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: ThreadGetRequest): SMono[InvocationWithContext] =
     getThreadResponse(request, mailboxSession)
       .reduce(ThreadGetResult.empty)(ThreadGetResult.merge)
       .map(threadGetResult => threadGetResult.asResponse(request.accountId))
@@ -75,7 +75,6 @@ class ThreadGetMethod @Inject()(val metricFactory: MetricFactory,
         arguments = Arguments(ThreadSerializer.serialize(threadGetResponse)),
         methodCallId = invocation.invocation.methodCallId))
       .map(InvocationWithContext(_, invocation.processingContext))
-  }
 
   override def getRequest(mailboxSession: MailboxSession, invocation: Invocation): Either[IllegalArgumentException, ThreadGetRequest] =
     ThreadSerializer.deserialize(invocation.arguments.value) match {
@@ -84,17 +83,15 @@ class ThreadGetMethod @Inject()(val metricFactory: MetricFactory,
     }
 
   private def getThreadResponse(threadGetRequest: ThreadGetRequest,
-                                mailboxSession: MailboxSession): SFlux[ThreadGetResult] = {
+                                mailboxSession: MailboxSession): SFlux[ThreadGetResult] =
     SFlux.fromIterable(threadGetRequest.ids)
       .flatMap(unparsedThreadId => {
         Try(threadIdFactory.fromString(unparsedThreadId.id.toString()))
-          .fold(e => SFlux.just(ThreadGetResult.notFound(unparsedThreadId)),
+          .fold(_ => SFlux.just(ThreadGetResult.notFound(unparsedThreadId)),
             threadId => SFlux.fromPublisher(mailboxManager.getThread(threadId, mailboxSession))
               .collectSeq()
               .map(seq => Thread(id = unparsedThreadId.id, emailIds = seq.toList))
               .map(ThreadGetResult.found)
               .onErrorResume((_ => SMono.just(ThreadGetResult.notFound(unparsedThreadId)))))
       })
-  }
-
 }

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


[james-project] 02/02: JAMES-3516 Fix Thread/get error management

Posted by bt...@apache.org.
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 869b1979917f9116c856787039cfc4132457aea2
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Oct 18 21:37:02 2021 +0700

    JAMES-3516 Fix Thread/get error management
    
    Unexpected errors should not be reported as `notFound` but should
    lead to a top level method failure (`serverFail`)
---
 .../main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
index 8496d9f..13ea9d3 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/ThreadGetMethod.scala
@@ -27,6 +27,7 @@ import org.apache.james.jmap.core.{AccountId, Invocation, UuidState}
 import org.apache.james.jmap.json.{ResponseSerializer, ThreadSerializer}
 import org.apache.james.jmap.mail.{Thread, ThreadGetRequest, ThreadGetResponse, ThreadNotFound, UnparsedThreadId}
 import org.apache.james.jmap.routes.SessionSupplier
+import org.apache.james.mailbox.exception.ThreadNotFoundException
 import org.apache.james.mailbox.model.{ThreadId => JavaThreadId}
 import org.apache.james.mailbox.{MailboxManager, MailboxSession}
 import org.apache.james.metrics.api.MetricFactory
@@ -92,6 +93,9 @@ class ThreadGetMethod @Inject()(val metricFactory: MetricFactory,
               .collectSeq()
               .map(seq => Thread(id = unparsedThreadId.id, emailIds = seq.toList))
               .map(ThreadGetResult.found)
-              .onErrorResume((_ => SMono.just(ThreadGetResult.notFound(unparsedThreadId)))))
+              .onErrorResume({
+                case _: ThreadNotFoundException => SMono.just(ThreadGetResult.notFound(unparsedThreadId))
+                case e => SMono.error(e)
+              }))
       })
 }

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