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 2020/10/28 04:53:26 UTC
[james-project] 01/10: JAMES-3436 Email/set create: Support keywords
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 17d98a0bc52cd1372911efdbb60bc973129e17f4
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Oct 26 14:24:47 2020 +0700
JAMES-3436 Email/set create: Support keywords
---
.../rfc8621/contract/EmailSetMethodContract.scala | 64 +++++++++++++++++++++-
.../org/apache/james/jmap/mail/EmailSet.scala | 3 +-
.../apache/james/jmap/method/EmailSetMethod.scala | 1 +
3 files changed, 66 insertions(+), 2 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/EmailSetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
index 0e8595b..6992bb6 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
@@ -223,12 +223,74 @@ trait EmailSetMethodContract {
assertThatJson(response)
.whenIgnoringPaths("methodResponses[1][1].list[0].id")
.inPath(s"methodResponses[1][1].list")
+ .isEqualTo(s"""[{
+ | "mailboxIds": {
+ | "${mailboxId.serialize}": true
+ | },
+ | "subject": "Boredome comes from a boring mind!"
+ |}]""".stripMargin)
+ }
+
+ @Test
+ def createShouldSupportKeywords(server: GuiceJamesServer): Unit = {
+ val bobPath = MailboxPath.inbox(BOB)
+ val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
+
+ val request = s"""{
+ | "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+ | "methodCalls": [
+ | ["Email/set", {
+ | "accountId": "$ACCOUNT_ID",
+ | "create": {
+ | "aaaaaa":{
+ | "mailboxIds": {
+ | "${mailboxId.serialize}": true
+ | },
+ | "keywords": {
+ | "$$answered": true,
+ | "music": true
+ | }
+ | }
+ | }
+ | }, "c1"],
+ | ["Email/get",
+ | {
+ | "accountId": "$ACCOUNT_ID",
+ | "ids": ["#aaaaaa"],
+ | "properties": ["mailboxIds", "keywords"]
+ | },
+ | "c2"]]
+ |}""".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)
+ .whenIgnoringPaths("methodResponses[0][1].created.aaaaaa.id")
+ .inPath("methodResponses[0][1].created.aaaaaa")
+ .isEqualTo("{}".stripMargin)
+
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[1][1].list[0].id")
+ .inPath(s"methodResponses[1][1].list")
.isEqualTo(
s"""[{
| "mailboxIds": {
| "${mailboxId.serialize}": true
| },
- | "subject": "Boredome comes from a boring mind!"
+ | "keywords": {
+ | "$$answered": true,
+ | "music": true
+ | }
|}]""".stripMargin)
}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSet.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSet.scala
index 5985147..baedcf7 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSet.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSet.scala
@@ -49,7 +49,8 @@ object EmailSet {
}
case class EmailCreationRequest(mailboxIds: MailboxIds,
- subject: Option[Subject]) {
+ subject: Option[Subject],
+ keywords: Option[Keywords]) {
def toMime4JMessage: Message = {
val builder = Message.Builder.of
subject.foreach(value => builder.setSubject(value.value))
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala
index e95abb9..759cd30 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSetMethod.scala
@@ -231,6 +231,7 @@ class EmailSetMethod @Inject()(serializer: EmailSetSerializer,
val appendResult = mailboxManager.getMailbox(mailboxId, mailboxSession)
.appendMessage(AppendCommand.builder()
.recent()
+ .withFlags(request.keywords.map(_.asFlags).getOrElse(new Flags()))
.build(request.toMime4JMessage),
mailboxSession)
CreationSuccess(clientId, EmailCreationResponse(appendResult.getId.getMessageId))
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org