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 48a2b94d5a916d3ef3609bee2918b8e75ddecfc3
Author: Rene Cordier <[email protected]>
AuthorDate: Wed Sep 23 13:43:00 2020 +0700

    JAMES-3384 size, from, to, subject and hasKeyword parameters are not yet 
supported for sorting on Email/query
---
 .../jmap/rfc8621/contract/EmailQueryMethodContract.scala |  7 ++++++-
 .../apache/james/jmap/json/EmailQuerySerializer.scala    |  7 ++++++-
 .../scala/org/apache/james/jmap/mail/EmailQuery.scala    | 16 +++++++++++++++-
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
index a3ec48c..0040ae2 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
@@ -870,7 +870,12 @@ trait EmailQueryMethodContract {
   @ParameterizedTest
   @ValueSource(strings = Array(
     "allInThreadHaveKeyword",
-    "someInThreadHaveKeyword"
+    "someInThreadHaveKeyword",
+    "size",
+    "from",
+    "to",
+    "subject",
+    "hasKeyword"
   ))
   def 
listMailsShouldReturnUnsupportedSortWhenPropertyFieldInComparatorIsValidButUnsupported(unsupported:
 String): Unit = {
     val request =
diff --git 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailQuerySerializer.scala
 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailQuerySerializer.scala
index 5d491dd..9d86b2b 100644
--- 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailQuerySerializer.scala
+++ 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/EmailQuerySerializer.scala
@@ -20,7 +20,7 @@
 package org.apache.james.jmap.json
 
 import javax.inject.Inject
-import org.apache.james.jmap.mail.{AllInThreadHaveKeywordSortProperty, Anchor, 
AnchorOffset, CollapseThreads, Collation, Comparator, EmailQueryRequest, 
EmailQueryResponse, FilterCondition, HasAttachment, IsAscending, 
ReceivedAtSortProperty, SomeInThreadHaveKeywordSortProperty, SortProperty}
+import org.apache.james.jmap.mail.{AllInThreadHaveKeywordSortProperty, Anchor, 
AnchorOffset, CollapseThreads, Collation, Comparator, EmailQueryRequest, 
EmailQueryResponse, FilterCondition, FromSortProperty, HasAttachment, 
HasKeywordSortProperty, IsAscending, ReceivedAtSortProperty, SizeSortProperty, 
SomeInThreadHaveKeywordSortProperty, SortProperty, SubjectSortProperty, 
ToSortProperty}
 import org.apache.james.jmap.model.{AccountId, CanCalculateChanges, Keyword, 
LimitUnparsed, PositionUnparsed, QueryState}
 import org.apache.james.mailbox.model.{MailboxId, MessageId}
 import play.api.libs.json._
@@ -61,6 +61,11 @@ class EmailQuerySerializer @Inject()(mailboxIdFactory: 
MailboxId.Factory) {
     case JsString("receivedAt") => JsSuccess(ReceivedAtSortProperty)
     case JsString("allInThreadHaveKeyword") => 
JsSuccess(AllInThreadHaveKeywordSortProperty)
     case JsString("someInThreadHaveKeyword") => 
JsSuccess(SomeInThreadHaveKeywordSortProperty)
+    case JsString("size") => JsSuccess(SizeSortProperty)
+    case JsString("from") => JsSuccess(FromSortProperty)
+    case JsString("to") => JsSuccess(ToSortProperty)
+    case JsString("subject") => JsSuccess(SubjectSortProperty)
+    case JsString("hasKeyword") => JsSuccess(HasKeywordSortProperty)
     case JsString(others) => JsError(s"'$others' is not a supported sort 
property")
     case _ => JsError(s"Expecting a JsString to represent a sort property")
   }
diff --git 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailQuery.scala
 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailQuery.scala
index 093030e..4856bbc 100644
--- 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailQuery.scala
+++ 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailQuery.scala
@@ -63,10 +63,24 @@ case object ReceivedAtSortProperty extends SortProperty {
 case object AllInThreadHaveKeywordSortProperty extends SortProperty {
   override def toSortClause: Either[UnsupportedSortException, SortClause] = 
Left(UnsupportedSortException("allInThreadHaveKeyword"))
 }
-
 case object SomeInThreadHaveKeywordSortProperty extends SortProperty {
   override def toSortClause: Either[UnsupportedSortException, SortClause] = 
Left(UnsupportedSortException("someInThreadHaveKeyword"))
 }
+case object SizeSortProperty extends SortProperty {
+  override def toSortClause: Either[UnsupportedSortException, SortClause] = 
Left(UnsupportedSortException("size"))
+}
+case object FromSortProperty extends SortProperty {
+  override def toSortClause: Either[UnsupportedSortException, SortClause] = 
Left(UnsupportedSortException("from"))
+}
+case object ToSortProperty extends SortProperty {
+  override def toSortClause: Either[UnsupportedSortException, SortClause] = 
Left(UnsupportedSortException("to"))
+}
+case object SubjectSortProperty extends SortProperty {
+  override def toSortClause: Either[UnsupportedSortException, SortClause] = 
Left(UnsupportedSortException("subject"))
+}
+case object HasKeywordSortProperty extends SortProperty {
+  override def toSortClause: Either[UnsupportedSortException, SortClause] = 
Left(UnsupportedSortException("hasKeyword"))
+}
 
 object IsAscending {
   val DESCENDING: IsAscending = IsAscending(false)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to