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 2023/02/21 01:17:56 UTC
[james-project] branch master updated (6a601becc2 -> 54151b5321)
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 6a601becc2 JAMES-3886 Handle Mailbox counter updates failures more gracefully (#1445)
new bc6fed8ebb JAMES-3440 Email/query (EmailQueryView usage case) should filter share mailboxes
new 54151b5321 JAMES-3440 Clarify EmailQueryView APIs naming
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:
.../projections/CassandraEmailQueryView.java | 6 +-
.../james/jmap/api/projections/EmailQueryView.java | 12 +-
.../memory/projections/MemoryEmailQueryView.java | 6 +-
.../api/projections/EmailQueryViewContract.java | 30 +-
.../jmap/draft/methods/GetMessageListMethod.java | 4 +-
.../event/PopulateEmailQueryViewListenerTest.java | 12 +-
.../contract/EmailQueryMethodContract.scala | 592 +++++++++++++++++++++
.../james/jmap/method/EmailQueryMethod.scala | 47 +-
.../PopulateEmailQueryViewRequestToTaskTest.java | 6 +-
9 files changed, 658 insertions(+), 57 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-3440 Email/query (EmailQueryView usage case) should filter share mailboxes
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 bc6fed8ebb10ab516259849c68a2e4b97665f106
Author: Quan Tran <hq...@linagora.com>
AuthorDate: Mon Feb 20 17:23:03 2023 +0700
JAMES-3440 Email/query (EmailQueryView usage case) should filter share mailboxes
---
.../contract/EmailQueryMethodContract.scala | 592 +++++++++++++++++++++
.../james/jmap/method/EmailQueryMethod.scala | 41 +-
2 files changed, 617 insertions(+), 16 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 480d078406..2773022055 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
@@ -710,6 +710,304 @@ trait EmailQueryMethodContract {
}
}
+ @Test
+ def inMailboxFilterWithSortedByReceivedAtShouldReturnEmptyForSharedMailboxesWhenNoSharesExtension(server: GuiceJamesServer): Unit = {
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "receivedAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState()}",
+ | "canCalculateChanges": false,
+ | "ids": [
+ |
+ | ],
+ | "position": 0,
+ | "limit": 256
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def inMailboxFilterWithSortedByReceivedAtShouldAcceptSharedMailboxesWhenSharesExtension(server: GuiceJamesServer): Unit = {
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ val messageId1: MessageId = mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail",
+ | "urn:apache:james:params:jmap:mail:shares"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "receivedAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ awaitAtMostTenSeconds.untilAsserted { () =>
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [[
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState(messageId1)}",
+ | "canCalculateChanges": false,
+ | "position": 0,
+ | "limit": 256,
+ | "ids": ["${messageId1.serialize()}"]
+ | },
+ | "c1"
+ | ]]
+ |}""".stripMargin)
+ }
+ }
+
+ @Test
+ def inMailboxFilterWithSortedBySentAtShouldReturnEmptyForSharedMailboxesWhenNoSharesExtension(server: GuiceJamesServer): Unit = {
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "sentAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState()}",
+ | "canCalculateChanges": false,
+ | "ids": [
+ |
+ | ],
+ | "position": 0,
+ | "limit": 256
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def inMailboxFilterWithSortedBySentAtShouldAcceptSharedMailboxesWhenSharesExtension(server: GuiceJamesServer): Unit = {
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ val messageId1: MessageId = mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail",
+ | "urn:apache:james:params:jmap:mail:shares"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "sentAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ awaitAtMostTenSeconds.untilAsserted { () =>
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [[
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState(messageId1)}",
+ | "canCalculateChanges": false,
+ | "position": 0,
+ | "limit": 256,
+ | "ids": ["${messageId1.serialize()}"]
+ | },
+ | "c1"
+ | ]]
+ |}""".stripMargin)
+ }
+ }
+
@Test
def inMailboxOtherThanFilterShouldReturnEmptyForSharedMailboxesWhenNoExtension(server: GuiceJamesServer): Unit = {
val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
@@ -771,6 +1069,300 @@ trait EmailQueryMethodContract {
|}""".stripMargin)
}
+ @Test
+ def inMailboxAfterWithSortedBySentAtShouldReturnEmptyForSharedMailboxesWhenNoSharesExtension(server: GuiceJamesServer): Unit = {
+ val requestDate = ZonedDateTime.now().minusDays(1)
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}",
+ | "after": "${UTCDate(requestDate).asUTC.format(UTC_DATE_FORMAT)}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "sentAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [[
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState()}",
+ | "canCalculateChanges": false,
+ | "ids": [],
+ | "position": 0,
+ | "limit": 256
+ | },
+ | "c1"
+ | ]]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def inMailboxAfterWithSortedBySentAtShouldAcceptSharedMailboxesWhenSharesExtension(server: GuiceJamesServer): Unit = {
+ val requestDate = ZonedDateTime.now().minusDays(1)
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ val messageId1: MessageId = mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail",
+ | "urn:apache:james:params:jmap:mail:shares"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}",
+ | "after": "${UTCDate(requestDate).asUTC.format(UTC_DATE_FORMAT)}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "sentAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [[
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState(messageId1)}",
+ | "canCalculateChanges": false,
+ | "ids": ["${messageId1.serialize()}"],
+ | "position": 0,
+ | "limit": 256
+ | },
+ | "c1"
+ | ]]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def inMailboxAfterWithSortedByReceivedAtShouldReturnEmptyForSharedMailboxesWhenNoSharesExtension(server: GuiceJamesServer): Unit = {
+ val requestDate = ZonedDateTime.now().minusDays(1)
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}",
+ | "after": "${UTCDate(requestDate).asUTC.format(UTC_DATE_FORMAT)}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "receivedAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [[
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState()}",
+ | "canCalculateChanges": false,
+ | "ids": [],
+ | "position": 0,
+ | "limit": 256
+ | },
+ | "c1"
+ | ]]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def inMailboxAfterWithSortedByReceivedAtShouldAcceptSharedMailboxesWhenSharesExtension(server: GuiceJamesServer): Unit = {
+ val requestDate = ZonedDateTime.now().minusDays(1)
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val andreInboxId = mailboxProbe.createMailbox(inbox(ANDRE))
+ val messageId1: MessageId = mailboxProbe
+ .appendMessage(ANDRE.asString, inbox(ANDRE),
+ AppendCommand.from(
+ Message.Builder
+ .of
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build))
+ .getMessageId
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .addRights(inbox(ANDRE), BOB.asString, new MailboxACL.Rfc4314Rights(Right.Read, Right.Lookup))
+
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail",
+ | "urn:apache:james:params:jmap:mail:shares"
+ | ],
+ | "methodCalls": [
+ | [
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter": {
+ | "inMailbox": "${andreInboxId.serialize()}",
+ | "after": "${UTCDate(requestDate).asUTC.format(UTC_DATE_FORMAT)}"
+ | },
+ | "sort": [{
+ | "isAscending": false,
+ | "property": "receivedAt"
+ | }]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [[
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "queryState": "${generateQueryState(messageId1)}",
+ | "canCalculateChanges": false,
+ | "ids": ["${messageId1.serialize()}"],
+ | "position": 0,
+ | "limit": 256
+ | },
+ | "c1"
+ | ]]
+ |}""".stripMargin)
+ }
+
@Test
def inMailboxOtherThanFilterShouldAcceptSharedMailboxesWhenExtension(server: GuiceJamesServer): Unit = {
val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
index 7bd1e09ad7..29692e118f 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
@@ -18,8 +18,12 @@
****************************************************************/
package org.apache.james.jmap.method
+import java.time.ZonedDateTime
+
import cats.implicits._
import eu.timepit.refined.auto._
+import javax.inject.Inject
+import javax.mail.Flags.Flag.DELETED
import org.apache.james.jmap.JMAPConfiguration
import org.apache.james.jmap.api.projections.EmailQueryView
import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
@@ -33,15 +37,12 @@ import org.apache.james.jmap.routes.SessionSupplier
import org.apache.james.jmap.utils.search.MailboxFilter
import org.apache.james.jmap.utils.search.MailboxFilter.QueryFilter
import org.apache.james.mailbox.exception.MailboxNotFoundException
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery.Namespace
import org.apache.james.mailbox.model.{MailboxId, MessageId, MultimailboxesSearchQuery, SearchQuery}
import org.apache.james.mailbox.{MailboxManager, MailboxSession}
import org.apache.james.metrics.api.MetricFactory
import org.apache.james.util.streams.{Limit => JavaLimit}
import reactor.core.scala.publisher.{SFlux, SMono}
-import java.time.ZonedDateTime
-
-import javax.inject.Inject
-import javax.mail.Flags.Flag.DELETED
import scala.jdk.CollectionConverters._
@@ -93,73 +94,81 @@ class EmailQueryMethod @Inject() (serializer: EmailQuerySerializer,
private def executeQuery(session: MailboxSession, request: EmailQueryRequest, searchQuery: MultimailboxesSearchQuery, position: Position, limit: Limit): SMono[EmailQueryResponse] = {
val ids: SMono[Seq[MessageId]] = request match {
case request: EmailQueryRequest if matchesInMailboxSortedBySentAt(request) =>
- queryViewForListingSortedBySentAt(session, position, limit, request)
+ queryViewForListingSortedBySentAt(session, position, limit, request, searchQuery.getNamespace)
case request: EmailQueryRequest if matchesInMailboxAfterSortedBySentAt(request) =>
- queryViewForContentAfterSortedBySentAt(session, position, limit, request)
+ queryViewForContentAfterSortedBySentAt(session, position, limit, request, searchQuery.getNamespace)
case request: EmailQueryRequest if matchesInMailboxSortedByReceivedAt(request) =>
- queryViewForListingSortedByReceivedAt(session, position, limit, request)
+ queryViewForListingSortedByReceivedAt(session, position, limit, request, searchQuery.getNamespace)
case request: EmailQueryRequest if matchesInMailboxAfterSortedByReceivedAt(request) =>
- queryViewForContentAfterSortedByReceivedAt(session, position, limit, request)
+ queryViewForContentAfterSortedByReceivedAt(session, position, limit, request, searchQuery.getNamespace)
case _ => executeQueryAgainstSearchIndex(session, searchQuery, position, limit)
}
ids.map(ids => toResponse(request, position, limit, ids))
}
- private def queryViewForContentAfterSortedBySentAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest): SMono[Seq[MessageId]] = {
+ private def queryViewForContentAfterSortedBySentAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest, namespace: Namespace): SMono[Seq[MessageId]] = {
val condition: FilterCondition = request.filter.get.asInstanceOf[FilterCondition]
val mailboxId: MailboxId = condition.inMailbox.get
val after: ZonedDateTime = condition.after.get.asUTC
SMono(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
- .`then`(SFlux.fromPublisher(
+ .filter(messageManager => namespace.keepAccessible(messageManager.getMailboxEntity))
+ .flatMap(_ => SFlux.fromPublisher(
emailQueryView.listMailboxContentSinceReceivedAt(mailboxId, after, JavaLimit.from(limitToUse.value + position.value)))
.drop(position.value)
.take(limitToUse.value)
.collectSeq())
+ .switchIfEmpty(SMono.just[Seq[MessageId]](Seq()))
.onErrorResume({
case _: MailboxNotFoundException => SMono.just[Seq[MessageId]](Seq())
case e => SMono.error[Seq[MessageId]](e)
})
}
- private def queryViewForContentAfterSortedByReceivedAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest): SMono[Seq[MessageId]] = {
+ private def queryViewForContentAfterSortedByReceivedAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest, namespace: Namespace): SMono[Seq[MessageId]] = {
val condition: FilterCondition = request.filter.get.asInstanceOf[FilterCondition]
val mailboxId: MailboxId = condition.inMailbox.get
val after: ZonedDateTime = condition.after.get.asUTC
SMono(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
- .`then`(SFlux.fromPublisher(
+ .filter(messageManager => namespace.keepAccessible(messageManager.getMailboxEntity))
+ .flatMap(_ => SFlux.fromPublisher(
emailQueryView.listMailboxContentSinceReceivedAtSortedByReceivedAt(mailboxId, after, JavaLimit.from(limitToUse.value + position.value)))
.drop(position.value)
.take(limitToUse.value)
.collectSeq())
+ .switchIfEmpty(SMono.just[Seq[MessageId]](Seq()))
.onErrorResume({
case _: MailboxNotFoundException => SMono.just[Seq[MessageId]](Seq())
case e => SMono.error[Seq[MessageId]](e)
})
}
- private def queryViewForListingSortedBySentAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest): SMono[Seq[MessageId]] = {
+ private def queryViewForListingSortedBySentAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest, namespace: Namespace): SMono[Seq[MessageId]] = {
val mailboxId: MailboxId = request.filter.get.asInstanceOf[FilterCondition].inMailbox.get
SMono(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
- .`then`(SFlux.fromPublisher(
+ .filter(messageManager => namespace.keepAccessible(messageManager.getMailboxEntity))
+ .flatMap(_ => SFlux.fromPublisher(
emailQueryView.listMailboxContent(mailboxId, JavaLimit.from(limitToUse.value + position.value)))
.drop(position.value)
.take(limitToUse.value)
.collectSeq())
+ .switchIfEmpty(SMono.just[Seq[MessageId]](Seq()))
.onErrorResume({
case _: MailboxNotFoundException => SMono.just[Seq[MessageId]](Seq())
case e => SMono.error[Seq[MessageId]](e)
})
}
- private def queryViewForListingSortedByReceivedAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest): SMono[Seq[MessageId]] = {
+ private def queryViewForListingSortedByReceivedAt(mailboxSession: MailboxSession, position: Position, limitToUse: Limit, request: EmailQueryRequest, namespace: Namespace): SMono[Seq[MessageId]] = {
val mailboxId: MailboxId = request.filter.get.asInstanceOf[FilterCondition].inMailbox.get
SMono(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
- .`then`(SFlux.fromPublisher(
+ .filter(messageManager => namespace.keepAccessible(messageManager.getMailboxEntity))
+ .flatMap(_ => SFlux.fromPublisher(
emailQueryView.listMailboxContentSortedByReceivedAt(mailboxId, JavaLimit.from(limitToUse.value + position.value)))
.drop(position.value)
.take(limitToUse.value)
.collectSeq())
+ .switchIfEmpty(SMono.just[Seq[MessageId]](Seq()))
.onErrorResume({
case _: MailboxNotFoundException => SMono.just[Seq[MessageId]](Seq())
case e => SMono.error[Seq[MessageId]](e)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 02/02: JAMES-3440 Clarify EmailQueryView APIs naming
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 54151b532160f546c635cf7b2559aa01aa3c6065
Author: Quan Tran <hq...@linagora.com>
AuthorDate: Mon Feb 20 17:31:43 2023 +0700
JAMES-3440 Clarify EmailQueryView APIs naming
---
.../projections/CassandraEmailQueryView.java | 6 ++---
.../james/jmap/api/projections/EmailQueryView.java | 12 ++++-----
.../memory/projections/MemoryEmailQueryView.java | 6 ++---
.../api/projections/EmailQueryViewContract.java | 30 +++++++++++-----------
.../jmap/draft/methods/GetMessageListMethod.java | 4 +--
.../event/PopulateEmailQueryViewListenerTest.java | 12 ++++-----
.../james/jmap/method/EmailQueryMethod.scala | 6 ++---
.../PopulateEmailQueryViewRequestToTaskTest.java | 6 ++---
8 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/projections/CassandraEmailQueryView.java b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/projections/CassandraEmailQueryView.java
index 20cae833cf..c409361cd2 100644
--- a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/projections/CassandraEmailQueryView.java
+++ b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/projections/CassandraEmailQueryView.java
@@ -166,7 +166,7 @@ public class CassandraEmailQueryView implements EmailQueryView {
}
@Override
- public Flux<MessageId> listMailboxContent(MailboxId mailboxId, Limit limit) {
+ public Flux<MessageId> listMailboxContentSortedBySentAt(MailboxId mailboxId, Limit limit) {
Preconditions.checkArgument(!limit.isUnlimited(), "Limit should be defined");
CassandraId cassandraId = (CassandraId) mailboxId;
@@ -188,7 +188,7 @@ public class CassandraEmailQueryView implements EmailQueryView {
}
@Override
- public Flux<MessageId> listMailboxContentSinceReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
+ public Flux<MessageId> listMailboxContentSinceAfterSortedBySentAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
Preconditions.checkArgument(!limit.isUnlimited(), "Limit should be defined");
CassandraId cassandraId = (CassandraId) mailboxId;
@@ -208,7 +208,7 @@ public class CassandraEmailQueryView implements EmailQueryView {
}
@Override
- public Flux<MessageId> listMailboxContentSinceReceivedAtSortedByReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
+ public Flux<MessageId> listMailboxContentSinceAfterSortedByReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
Preconditions.checkArgument(!limit.isUnlimited(), "Limit should be defined");
CassandraId cassandraId = (CassandraId) mailboxId;
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/EmailQueryView.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/EmailQueryView.java
index ff0e9caa22..41247aca8f 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/EmailQueryView.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/projections/EmailQueryView.java
@@ -103,7 +103,7 @@ public interface EmailQueryView {
*
* @return messageIds of the messages in this mailbox, sorted by sentAt.
*/
- Flux<MessageId> listMailboxContent(MailboxId mailboxId, Limit limit);
+ Flux<MessageId> listMailboxContentSortedBySentAt(MailboxId mailboxId, Limit limit);
/**
*
@@ -124,7 +124,7 @@ public interface EmailQueryView {
* },
* "c1"]
*
- * @return messageIds of the messages in this mailbox, sorted by sentAt.
+ * @return messageIds of the messages in this mailbox, sorted by receivedAt.
*/
Flux<MessageId> listMailboxContentSortedByReceivedAt(MailboxId mailboxId, Limit limit);
@@ -147,9 +147,9 @@ public interface EmailQueryView {
* },
* "c1"]
*
- * @return messageIds of the messages in this mailbox, since being receivedAt. Sorted by sentAt.
+ * @return messageIds of the messages in this mailbox, since being "after". Sorted by sentAt.
*/
- Flux<MessageId> listMailboxContentSinceReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit);
+ Flux<MessageId> listMailboxContentSinceAfterSortedBySentAt(MailboxId mailboxId, ZonedDateTime since, Limit limit);
/**
* Sample JMAP requests:
@@ -170,9 +170,9 @@ public interface EmailQueryView {
* },
* "c1"]
*
- * @return messageIds of the messages in this mailbox, since being receivedAt. Sorted by sentAt.
+ * @return messageIds of the messages in this mailbox, since being "after". Sorted by receivedAt.
*/
- Flux<MessageId> listMailboxContentSinceReceivedAtSortedByReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit);
+ Flux<MessageId> listMailboxContentSinceAfterSortedByReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit);
/**
* Sample JMAP requests:
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/projections/MemoryEmailQueryView.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/projections/MemoryEmailQueryView.java
index c5cbfea5c1..ee1648fbc2 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/projections/MemoryEmailQueryView.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/projections/MemoryEmailQueryView.java
@@ -46,7 +46,7 @@ public class MemoryEmailQueryView implements EmailQueryView {
}
@Override
- public Flux<MessageId> listMailboxContent(MailboxId mailboxId, Limit limit) {
+ public Flux<MessageId> listMailboxContentSortedBySentAt(MailboxId mailboxId, Limit limit) {
Preconditions.checkArgument(!limit.isUnlimited(), "Limit should be defined");
return Flux.fromIterable(entries.row(mailboxId).values())
@@ -67,7 +67,7 @@ public class MemoryEmailQueryView implements EmailQueryView {
}
@Override
- public Flux<MessageId> listMailboxContentSinceReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
+ public Flux<MessageId> listMailboxContentSinceAfterSortedBySentAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
Preconditions.checkArgument(!limit.isUnlimited(), "Limit should be defined");
return Flux.fromIterable(entries.row(mailboxId).values())
@@ -86,7 +86,7 @@ public class MemoryEmailQueryView implements EmailQueryView {
}
@Override
- public Flux<MessageId> listMailboxContentSinceReceivedAtSortedByReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
+ public Flux<MessageId> listMailboxContentSinceAfterSortedByReceivedAt(MailboxId mailboxId, ZonedDateTime since, Limit limit) {
return Flux.fromIterable(entries.row(mailboxId).values())
.filter(e -> e.getReceivedAt().isAfter(since) || e.getReceivedAt().isEqual(since))
.sort(Comparator.comparing(Entry::getReceivedAt).reversed())
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/EmailQueryViewContract.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/EmailQueryViewContract.java
index b792795e83..4570da538b 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/EmailQueryViewContract.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/EmailQueryViewContract.java
@@ -53,7 +53,7 @@ public interface EmailQueryViewContract {
@Test
default void listMailboxContentShouldReturnEmptyByDefault() {
- assertThat(testee().listMailboxContent(mailboxId1(), Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.limit(12)).collectList().block())
.isEmpty();
}
@@ -63,7 +63,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_3, DATE_4, messageId2()).block();
testee().save(mailboxId1(), DATE_2, DATE_6, messageId3()).block();
- assertThat(testee().listMailboxContent(mailboxId1(), Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.limit(12)).collectList().block())
.containsExactly(messageId2(), messageId3(), messageId1());
}
@@ -73,7 +73,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_3, DATE_4, messageId2()).block();
testee().save(mailboxId1(), DATE_2, DATE_6, messageId3()).block();
- assertThat(testee().listMailboxContent(mailboxId1(), Limit.limit(2)).collectList().block())
+ assertThat(testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.limit(2)).collectList().block())
.containsExactly(messageId2(), messageId3());
}
@@ -83,7 +83,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_3, DATE_4, messageId2()).block();
testee().save(mailboxId1(), DATE_5, DATE_6, messageId3()).block();
- assertThat(testee().listMailboxContentSinceReceivedAt(mailboxId1(), DATE_3, Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSinceAfterSortedBySentAt(mailboxId1(), DATE_3, Limit.limit(12)).collectList().block())
.containsExactly(messageId3(), messageId2());
}
@@ -93,7 +93,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_3, DATE_4, messageId2()).block();
testee().save(mailboxId1(), DATE_5, DATE_6, messageId3()).block();
- assertThat(testee().listMailboxContentSinceReceivedAt(mailboxId1(), DATE_7, Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSinceAfterSortedBySentAt(mailboxId1(), DATE_7, Limit.limit(12)).collectList().block())
.isEmpty();
}
@@ -103,7 +103,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_3, DATE_4, messageId2()).block();
testee().save(mailboxId1(), DATE_5, DATE_6, messageId3()).block();
- assertThat(testee().listMailboxContentSinceReceivedAt(mailboxId1(), DATE_1, Limit.limit(2)).collectList().block())
+ assertThat(testee().listMailboxContentSinceAfterSortedBySentAt(mailboxId1(), DATE_1, Limit.limit(2)).collectList().block())
.containsExactly(messageId3(), messageId2());
}
@@ -145,7 +145,7 @@ public interface EmailQueryViewContract {
testee().delete(mailboxId1()).block();
- assertThat(testee().listMailboxContent(mailboxId1(), Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.limit(12)).collectList().block())
.isEmpty();
}
@@ -157,7 +157,7 @@ public interface EmailQueryViewContract {
testee().delete(mailboxId1(), messageId2()).block();
- assertThat(testee().listMailboxContent(mailboxId1(), Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.limit(12)).collectList().block())
.containsExactly(messageId3(), messageId1());
}
@@ -169,7 +169,7 @@ public interface EmailQueryViewContract {
testee().delete(mailboxId1()).block();
- assertThat(testee().listMailboxContentSinceReceivedAt(mailboxId1(), DATE_4, Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSinceAfterSortedBySentAt(mailboxId1(), DATE_4, Limit.limit(12)).collectList().block())
.isEmpty();
}
@@ -190,7 +190,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_1, DATE_2, messageId1()).block();
testee().save(mailboxId1(), DATE_1, DATE_2, messageId1()).block();
- assertThat(testee().listMailboxContent(mailboxId1(), Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.limit(12)).collectList().block())
.containsExactly(messageId1());
}
@@ -199,7 +199,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_1, DATE_2, messageId1()).block();
testee().save(mailboxId1(), DATE_1, DATE_2, messageId2()).block();
- assertThat(testee().listMailboxContent(mailboxId1(), Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.limit(12)).collectList().block())
.containsExactly(messageId1(), messageId2());
}
@@ -211,7 +211,7 @@ public interface EmailQueryViewContract {
testee().delete(mailboxId1(), messageId2()).block();
- assertThat(testee().listMailboxContentSinceReceivedAt(mailboxId1(), DATE_3, Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSinceAfterSortedBySentAt(mailboxId1(), DATE_3, Limit.limit(12)).collectList().block())
.containsExactly(messageId3());
}
@@ -243,7 +243,7 @@ public interface EmailQueryViewContract {
testee().save(mailboxId1(), DATE_2, DATE_3, messageId2()).block();
testee().save(mailboxId1(), DATE_5, DATE_6, messageId3()).block();
- assertThat(testee().listMailboxContentSinceReceivedAtSortedByReceivedAt(mailboxId1(), DATE_4, Limit.limit(12)).collectList().block())
+ assertThat(testee().listMailboxContentSinceAfterSortedByReceivedAt(mailboxId1(), DATE_4, Limit.limit(12)).collectList().block())
.containsExactly(messageId3(), messageId1());
}
@@ -259,7 +259,7 @@ public interface EmailQueryViewContract {
@Test
default void listMailboxContentShouldThrowOnUndefinedLimit() {
- assertThatThrownBy(() -> testee().listMailboxContent(mailboxId1(), Limit.unlimited()).blockLast())
+ assertThatThrownBy(() -> testee().listMailboxContentSortedBySentAt(mailboxId1(), Limit.unlimited()).blockLast())
.isInstanceOf(IllegalArgumentException.class);
}
@@ -271,7 +271,7 @@ public interface EmailQueryViewContract {
@Test
default void listMailboxContentSinceReceivedAtShouldThrowOnUndefinedLimit() {
- assertThatThrownBy(() -> testee().listMailboxContentSinceReceivedAt(mailboxId1(), DATE_3, Limit.unlimited()).blockLast())
+ assertThatThrownBy(() -> testee().listMailboxContentSinceAfterSortedBySentAt(mailboxId1(), DATE_3, Limit.unlimited()).blockLast())
.isInstanceOf(IllegalArgumentException.class);
}
}
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java
index 325101bda3..2ab9165954 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java
@@ -179,7 +179,7 @@ public class GetMessageListMethod implements Method {
Limit aLimit = Limit.from(Math.toIntExact(limit));
return Mono.from(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
- .then(emailQueryView.listMailboxContent(mailboxId, aLimit)
+ .then(emailQueryView.listMailboxContentSortedBySentAt(mailboxId, aLimit)
.skip(position)
.take(limit)
.reduce(GetMessageListResponse.builder(), GetMessageListResponse.Builder::messageId)
@@ -195,7 +195,7 @@ public class GetMessageListMethod implements Method {
Limit aLimit = Limit.from(Math.toIntExact(limit));
return Mono.from(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
- .then(emailQueryView.listMailboxContentSinceReceivedAt(mailboxId, after, aLimit)
+ .then(emailQueryView.listMailboxContentSinceAfterSortedBySentAt(mailboxId, after, aLimit)
.skip(position)
.take(limit)
.reduce(GetMessageListResponse.builder(), GetMessageListResponse.Builder::messageId)
diff --git a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/event/PopulateEmailQueryViewListenerTest.java b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/event/PopulateEmailQueryViewListenerTest.java
index 98a75c3645..2f62f4414a 100644
--- a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/event/PopulateEmailQueryViewListenerTest.java
+++ b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/event/PopulateEmailQueryViewListenerTest.java
@@ -128,7 +128,7 @@ public class PopulateEmailQueryViewListenerTest {
.build(emptyMessage(Date.from(ZonedDateTime.parse("2014-10-30T14:12:00Z").toInstant()))),
mailboxSession).getId();
- assertThat(view.listMailboxContent(inboxId, Limit.limit(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(inboxId, Limit.limit(12)).collectList().block())
.containsOnly(composedId.getMessageId());
}
@@ -141,7 +141,7 @@ public class PopulateEmailQueryViewListenerTest {
.build(emptyMessage(Date.from(ZonedDateTime.parse("2014-10-30T14:12:00Z").toInstant()))),
mailboxSession).getId();
- assertThat(view.listMailboxContent(inboxId, Limit.limit(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(inboxId, Limit.limit(12)).collectList().block())
.isEmpty();
}
@@ -156,7 +156,7 @@ public class PopulateEmailQueryViewListenerTest {
inboxMessageManager.setFlags(new Flags(), MessageManager.FlagsUpdateMode.REPLACE, MessageRange.all(), mailboxSession);
- assertThat(view.listMailboxContent(inboxId, Limit.limit(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(inboxId, Limit.limit(12)).collectList().block())
.containsOnly(composedId.getMessageId());
}
@@ -170,7 +170,7 @@ public class PopulateEmailQueryViewListenerTest {
inboxMessageManager.setFlags(new Flags(DELETED), MessageManager.FlagsUpdateMode.REPLACE, MessageRange.all(), mailboxSession);
- assertThat(view.listMailboxContent(inboxId, Limit.limit(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(inboxId, Limit.limit(12)).collectList().block())
.isEmpty();
}
@@ -184,7 +184,7 @@ public class PopulateEmailQueryViewListenerTest {
mailboxManager.deleteMailbox(inboxId, mailboxSession);
- assertThat(view.listMailboxContent(inboxId, Limit.limit(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(inboxId, Limit.limit(12)).collectList().block())
.isEmpty();
}
@@ -198,7 +198,7 @@ public class PopulateEmailQueryViewListenerTest {
inboxMessageManager.delete(ImmutableList.of(composedMessageId.getUid()), mailboxSession);
- assertThat(view.listMailboxContent(inboxId, Limit.limit(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(inboxId, Limit.limit(12)).collectList().block())
.isEmpty();
}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
index 29692e118f..c61cb30f7f 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailQueryMethod.scala
@@ -114,7 +114,7 @@ class EmailQueryMethod @Inject() (serializer: EmailQuerySerializer,
SMono(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
.filter(messageManager => namespace.keepAccessible(messageManager.getMailboxEntity))
.flatMap(_ => SFlux.fromPublisher(
- emailQueryView.listMailboxContentSinceReceivedAt(mailboxId, after, JavaLimit.from(limitToUse.value + position.value)))
+ emailQueryView.listMailboxContentSinceAfterSortedBySentAt(mailboxId, after, JavaLimit.from(limitToUse.value + position.value)))
.drop(position.value)
.take(limitToUse.value)
.collectSeq())
@@ -132,7 +132,7 @@ class EmailQueryMethod @Inject() (serializer: EmailQuerySerializer,
SMono(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
.filter(messageManager => namespace.keepAccessible(messageManager.getMailboxEntity))
.flatMap(_ => SFlux.fromPublisher(
- emailQueryView.listMailboxContentSinceReceivedAtSortedByReceivedAt(mailboxId, after, JavaLimit.from(limitToUse.value + position.value)))
+ emailQueryView.listMailboxContentSinceAfterSortedByReceivedAt(mailboxId, after, JavaLimit.from(limitToUse.value + position.value)))
.drop(position.value)
.take(limitToUse.value)
.collectSeq())
@@ -148,7 +148,7 @@ class EmailQueryMethod @Inject() (serializer: EmailQuerySerializer,
SMono(mailboxManager.getMailboxReactive(mailboxId, mailboxSession))
.filter(messageManager => namespace.keepAccessible(messageManager.getMailboxEntity))
.flatMap(_ => SFlux.fromPublisher(
- emailQueryView.listMailboxContent(mailboxId, JavaLimit.from(limitToUse.value + position.value)))
+ emailQueryView.listMailboxContentSortedBySentAt(mailboxId, JavaLimit.from(limitToUse.value + position.value)))
.drop(position.value)
.take(limitToUse.value)
.collectSeq())
diff --git a/server/protocols/webadmin/webadmin-jmap/src/test/java/org/apache/james/webadmin/data/jmap/PopulateEmailQueryViewRequestToTaskTest.java b/server/protocols/webadmin/webadmin-jmap/src/test/java/org/apache/james/webadmin/data/jmap/PopulateEmailQueryViewRequestToTaskTest.java
index 87709db01e..6789e07095 100644
--- a/server/protocols/webadmin/webadmin-jmap/src/test/java/org/apache/james/webadmin/data/jmap/PopulateEmailQueryViewRequestToTaskTest.java
+++ b/server/protocols/webadmin/webadmin-jmap/src/test/java/org/apache/james/webadmin/data/jmap/PopulateEmailQueryViewRequestToTaskTest.java
@@ -265,7 +265,7 @@ class PopulateEmailQueryViewRequestToTaskTest {
.basePath(TasksRoutes.BASE)
.get(taskId + "/await");
- assertThat(view.listMailboxContent(messageId.getMailboxId(), Limit.from(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(messageId.getMailboxId(), Limit.from(12)).collectList().block())
.containsOnly(messageId.getMessageId());
}
@@ -287,7 +287,7 @@ class PopulateEmailQueryViewRequestToTaskTest {
.basePath(TasksRoutes.BASE)
.get(taskId + "/await");
- assertThat(view.listMailboxContent(messageId.getMailboxId(), Limit.from(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(messageId.getMailboxId(), Limit.from(12)).collectList().block())
.isEmpty();
}
@@ -315,7 +315,7 @@ class PopulateEmailQueryViewRequestToTaskTest {
.basePath(TasksRoutes.BASE)
.get(taskId2 + "/await");
- assertThat(view.listMailboxContent(messageId.getMailboxId(), Limit.from(12)).collectList().block())
+ assertThat(view.listMailboxContentSortedBySentAt(messageId.getMailboxId(), Limit.from(12)).collectList().block())
.containsOnly(messageId.getMessageId());
}
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org