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:44 UTC

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

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