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 9d16f687cea0924d1cc3e6b96e695031060dc966 Author: Benoit Tellier <[email protected]> AuthorDate: Tue Nov 3 17:11:48 2020 +0700 JAMES-3368 Follow the specification for default Email/get properties --- .../rfc8621/contract/EmailGetMethodContract.scala | 135 ++++++++++++++++++++- .../scala/org/apache/james/jmap/mail/Email.scala | 5 +- 2 files changed, 134 insertions(+), 6 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/EmailGetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala index 01ae19e..20a1800 100644 --- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala +++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala @@ -297,7 +297,8 @@ trait EmailGetMethodContract { | "Email/get", | { | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", - | "ids": ["${messageId.serialize}"] + | "ids": ["${messageId.serialize}"], + | "properties": ["id", "size"] | }, | "c1"]] |}""".stripMargin @@ -2263,7 +2264,8 @@ trait EmailGetMethodContract { | "Email/get", | { | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", - | "ids": ["${messageId.serialize}", "invalid", "${nonExistingMessageId.serialize}"] + | "ids": ["${messageId.serialize}", "invalid", "${nonExistingMessageId.serialize}"], + | "properties": ["id", "size"] | }, | "c1"]] |}""".stripMargin @@ -2324,7 +2326,8 @@ trait EmailGetMethodContract { | "Email/get", | { | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", - | "ids": ["${messageId1.serialize()}", "${messageId2.serialize()}"] + | "ids": ["${messageId1.serialize()}", "${messageId2.serialize()}"], + | "properties": ["id", "size"] | }, | "c1"]] |}""".stripMargin @@ -2366,6 +2369,126 @@ trait EmailGetMethodContract { } @Test + def useDefaultPropertiesWhenNone(server: GuiceJamesServer): Unit = { + val path = MailboxPath.inbox(BOB) + val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(path) + val messageId: MessageId = server.getProbe(classOf[MailboxProbeImpl]) + .appendMessage(BOB.asString, path, AppendCommand.builder() + .withInternalDate(Date.from(ZonedDateTime.parse("2014-10-30T14:12:00Z").toInstant)) + .build(ClassLoader.getSystemResourceAsStream("eml/multipart_simple.eml"))) + .getMessageId + + val request = + s"""{ + | "using": [ + | "urn:ietf:params:jmap:core", + | "urn:ietf:params:jmap:mail"], + | "methodCalls": [[ + | "Email/get", + | { + | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", + | "ids": ["${messageId.serialize}"] + | }, + | "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": "75128aab4b1b", + | "methodResponses": [ + | [ + | "Email/get", + | { + | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", + | "state": "000001", + | "list": [ + | { + | "threadId": "${messageId.serialize}", + | "size": 2695, + | "keywords": {}, + | "blobId": "1", + | "mailboxIds": {"${mailboxId.serialize}": true}, + | "id": "${messageId.serialize}", + | "receivedAt": "2014-10-30T14:12:00Z", + | "references": null, + | "subject": "MultiAttachment", + | "inReplyTo": null, + | "messageId": ["[email protected]"], + | "from": [{"name": "Lina","email": "[email protected]"}], + | "sentAt": "2017-02-27T04:24:48Z", + | "to": [{"email": "[email protected]"}], + | "textBody": [ + | { + | "partId": "2", + | "blobId": "${messageId.serialize}_2", + | "size": 8, + | "type": "text/plain", + | "charset": "utf-8" + | } + | ], + | "attachments": [ + | { + | "partId": "3", + | "blobId": "${messageId.serialize}_3", + | "size": 271, + | "name": "text1", + | "type": "text/plain", + | "charset": "UTF-8", + | "disposition": "attachment" + | }, + | { + | "partId": "4", + | "blobId": "${messageId.serialize}_4", + | "size": 398, + | "name": "text2", + | "type": "application/vnd.ms-publisher", + | "charset": "us-ascii", + | "disposition": "attachment" + | }, + | { + | "partId": "5", + | "blobId": "${messageId.serialize}_5", + | "size": 412, + | "name": "text3", + | "type": "text/plain", + | "charset": "UTF-8", + | "disposition": "attachment" + | } + | ], + | "htmlBody": [ + | { + | "partId": "2", + | "blobId": "${messageId.serialize}_2", + | "size": 8, + | "type": "text/plain", + | "charset": "utf-8" + | } + | ], + | "bodyValues": {}, + | "preview": "Send", + | "hasAttachment": true + | } + | ], + | "notFound": [] + | }, + | "c1" + | ] + | ] + |}""".stripMargin) + } + + @Test def requestingTheSameIdTwiceReturnsItOnce(server: GuiceJamesServer): Unit = { val message: Message = Message.Builder .of @@ -2386,7 +2509,8 @@ trait EmailGetMethodContract { | "Email/get", | { | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", - | "ids": ["${messageId.serialize}", "${messageId.serialize}"] + | "ids": ["${messageId.serialize}", "${messageId.serialize}"], + | "properties": ["id", "size"] | }, | "c1"]] |}""".stripMargin @@ -2766,7 +2890,8 @@ trait EmailGetMethodContract { | "Email/get", | { | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", - | "ids": ["${messageId.serialize}"] + | "ids": ["${messageId.serialize}"], + | "properties": ["id", "size"] | }, | "c1"]] |}""".stripMargin diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala index e978537..534b1ec 100644 --- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala +++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala @@ -63,7 +63,10 @@ object Email { type UnparsedEmailIdConstraint = NonEmpty type UnparsedEmailId = String Refined UnparsedEmailIdConstraint - val defaultProperties: Properties = Properties("id", "size") + val defaultProperties: Properties = Properties("id", "blobId", "threadId", "mailboxIds", "keywords", "size", + "receivedAt", "messageId", "inReplyTo", "references", "sender", "from", + "to", "cc", "bcc", "replyTo", "subject", "sentAt", "hasAttachment", + "preview", "bodyValues", "textBody", "htmlBody", "attachments") val allowedProperties: Properties = Properties("id", "size", "bodyStructure", "textBody", "htmlBody", "attachments", "headers", "bodyValues", "messageId", "inReplyTo", "references", "to", "cc", "bcc", "from", "sender", "replyTo", "subject", "sentAt", "mailboxIds", "blobId", "threadId", "receivedAt", --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
