You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/01/12 11:02:04 UTC
[james-project] 05/20: JAMES-3472 Update Email/changes request &
response
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c06ee0e28cd7cba7bb95ec24ceb2d854590ddd9e
Author: LanKhuat <dl...@linagora.com>
AuthorDate: Wed Jan 6 16:41:14 2021 +0700
JAMES-3472 Update Email/changes request & response
---
.../src/main/scala/org/apache/james/jmap/core/Session.scala | 4 +++-
.../org/apache/james/jmap/json/EmailGetSerializer.scala | 6 ++++++
.../src/main/scala/org/apache/james/jmap/mail/EmailGet.scala | 12 ++++++------
.../main/scala/org/apache/james/jmap/mail/MailboxGet.scala | 5 +++--
4 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala
index 81c3f4b..bca220a 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/Session.scala
@@ -28,7 +28,7 @@ import eu.timepit.refined.api.Refined
import eu.timepit.refined.refineV
import eu.timepit.refined.string.Uuid
import org.apache.james.core.Username
-import org.apache.james.jmap.api.change.{MailboxChanges, State => JavaState}
+import org.apache.james.jmap.api.change.{EmailChanges, MailboxChanges, State => JavaState}
import org.apache.james.jmap.core.CapabilityIdentifier.CapabilityIdentifier
import org.apache.james.jmap.core.Id.Id
import org.apache.james.jmap.core.State.INSTANCE
@@ -84,6 +84,8 @@ object State {
def fromMailboxChanges(mailboxChanges: MailboxChanges): State = fromJava(mailboxChanges.getNewState)
+ def fromEmailChanges(emailChanges: EmailChanges): State = fromJava(emailChanges.getNewState)
+
def fromJava(javaState: JavaState): State = State(javaState.getValue)
}
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 edc3392..4a45e02 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,6 +19,7 @@
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
@@ -109,6 +110,11 @@ 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/mail/EmailGet.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailGet.scala
index a9ff048..a3d63dc 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailGet.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailGet.scala
@@ -25,13 +25,13 @@ import eu.timepit.refined.api.Refined
import eu.timepit.refined.auto._
import eu.timepit.refined.numeric.NonNegative
import eu.timepit.refined.types.string.NonEmptyString
-import org.apache.james.jmap.core.Id.Id
-import org.apache.james.jmap.core.UnsignedInt.UnsignedInt
+import org.apache.james.jmap.api.change.Limit
import org.apache.james.jmap.core.{AccountId, Properties, State}
import org.apache.james.jmap.mail.Email.UnparsedEmailId
import org.apache.james.jmap.mail.EmailGetRequest.MaxBodyValueBytes
import org.apache.james.jmap.mail.EmailHeaders.SPECIFIC_HEADER_PREFIX
import org.apache.james.jmap.method.WithAccountId
+import org.apache.james.mailbox.model.MessageId
import org.apache.james.mime4j.dom.Message
import org.apache.james.mime4j.stream.Field
@@ -114,13 +114,13 @@ case class SpecificHeaderRequest(property: NonEmptyString, headerName: String, p
case class EmailChangesRequest(accountId: AccountId,
sinceState: State,
- maxChanged: Option[UnsignedInt]) extends WithAccountId
+ maxChanged: Option[Limit]) extends WithAccountId
case class EmailChangesResponse(accountId: AccountId,
oldState: State,
newState: State,
hasMoreChanges: HasMoreChanges,
- created: List[Id],
- updated: List[Id],
- destroyed: List[Id])
\ No newline at end of file
+ created: Set[MessageId],
+ updated: Set[MessageId],
+ destroyed: Set[MessageId])
\ No newline at end of file
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala
index a3a33e0..7f9fd33 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxGet.scala
@@ -22,8 +22,7 @@ package org.apache.james.jmap.mail
import eu.timepit.refined
import eu.timepit.refined.api.Refined
import eu.timepit.refined.collection.NonEmpty
-import org.apache.james.jmap.api.change.Limit
-import org.apache.james.jmap.api.change.MailboxChanges
+import org.apache.james.jmap.api.change.{EmailChanges, Limit, MailboxChanges}
import org.apache.james.jmap.core.{AccountId, Properties, State}
import org.apache.james.jmap.mail.MailboxGet.UnparsedMailboxId
import org.apache.james.jmap.method.WithAccountId
@@ -68,6 +67,8 @@ case class MailboxGetResponse(accountId: AccountId,
object HasMoreChanges {
def fromMailboxChanges(mailboxChanges: MailboxChanges): HasMoreChanges = HasMoreChanges(mailboxChanges.hasMoreChanges)
+
+ def fromEmailChanges(emailChanges: EmailChanges): HasMoreChanges = HasMoreChanges(emailChanges.hasMoreChanges)
}
case class HasMoreChanges(value: Boolean) extends AnyVal
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org