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/04/02 01:29:59 UTC
[james-project] 03/03: JAMES-3472 Factorize limit reads
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch 3.6.x
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 1c7b4597845f427254da92ffa27bc055851ed0c2
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Mar 31 17:21:36 2021 +0700
JAMES-3472 Factorize limit reads
---
.../main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala | 6 ------
.../main/scala/org/apache/james/jmap/json/MailboxSerializer.scala | 7 -------
.../src/main/scala/org/apache/james/jmap/json/package.scala | 6 ++++++
3 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
index 4a45e02..edc3392 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailGetSerializer.scala
@@ -19,7 +19,6 @@
package org.apache.james.jmap.json
-import org.apache.james.jmap.api.change.Limit
import org.apache.james.jmap.api.model.Preview
import org.apache.james.jmap.core.{Properties, State}
import org.apache.james.jmap.mail.Email.Size
@@ -110,11 +109,6 @@ object EmailGetSerializer {
private implicit val headersWrites: Writes[EmailHeader] = Json.writes[EmailHeader]
private implicit val bodyValueWrites: Writes[EmailBodyValue] = Json.writes[EmailBodyValue]
private implicit val emailIdsReads: Reads[EmailIds] = Json.valueReads[EmailIds]
- private implicit val limitReads: Reads[Limit] = {
- case JsNumber(underlying) if underlying > 0 => JsSuccess(Limit.of(underlying.intValue))
- case JsNumber(underlying) if underlying <= 0 => JsError("Expecting a positive integer as Limit")
- case _ => JsError("Expecting a number as Limit")
- }
private implicit val emailGetRequestReads: Reads[EmailGetRequest] = Json.reads[EmailGetRequest]
private implicit val emailChangesRequestReads: Reads[EmailChangesRequest] = Json.reads[EmailChangesRequest]
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala
index 90ef9e9..90f1a09 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/MailboxSerializer.scala
@@ -23,7 +23,6 @@ import eu.timepit.refined._
import eu.timepit.refined.collection.NonEmpty
import javax.inject.Inject
import org.apache.james.core.{Domain, Username}
-import org.apache.james.jmap.api.change.Limit
import org.apache.james.jmap.core.CapabilityIdentifier.CapabilityIdentifier
import org.apache.james.jmap.core.{ClientId, Properties, SetError, State}
import org.apache.james.jmap.mail.MailboxGet.{UnparsedMailboxId, UnparsedMailboxIdConstraint}
@@ -114,12 +113,6 @@ class MailboxSerializer @Inject()(mailboxIdFactory: MailboxId.Factory) {
private implicit val mailboxGetRequest: Reads[MailboxGetRequest] = Json.reads[MailboxGetRequest]
- private implicit val limitReads: Reads[Limit] = {
- case JsNumber(underlying) if underlying > 0 => JsSuccess(Limit.of(underlying.intValue))
- case JsNumber(underlying) if underlying <= 0 => JsError("Expecting a positive integer as Limit")
- case _ => JsError("Expecting a number as Limit")
- }
-
private implicit val mailboxChangesRequest: Reads[MailboxChangesRequest] = Json.reads[MailboxChangesRequest]
private implicit val mailboxRemoveEmailsOnDestroy: Reads[RemoveEmailsOnDestroy] = Json.valueFormat[RemoveEmailsOnDestroy]
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
index fb77977..28e3668 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/package.scala
@@ -24,6 +24,7 @@ import java.time.format.DateTimeFormatter
import eu.timepit.refined.api.{RefType, Validate}
import org.apache.james.core.MailAddress
+import org.apache.james.jmap.api.change.Limit
import org.apache.james.jmap.core.SetError.SetErrorDescription
import org.apache.james.jmap.core.{AccountId, Properties, SetError, State, UTCDate}
import org.apache.james.jmap.mail.HasMoreChanges
@@ -95,4 +96,9 @@ package object json {
private[json] implicit val utcDateWrites: Writes[UTCDate] =
utcDate => JsString(utcDate.asUTC.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX")))
private[json] implicit val hasMoreChangesWrites: Writes[HasMoreChanges] = Json.valueWrites[HasMoreChanges]
+ private[json] implicit val limitReads: Reads[Limit] = {
+ case JsNumber(underlying) if underlying > 0 => JsSuccess(Limit.of(underlying.intValue))
+ case JsNumber(underlying) if underlying <= 0 => JsError("Expecting a positive integer as Limit")
+ case _ => JsError("Expecting a number as Limit")
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org