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


The following commit(s) were added to refs/heads/master by this push:
     new 2384d3f  JAMES-3369 Email/get include inlined text in fetched 
properties (#685)
2384d3f is described below

commit 2384d3f577182b155cdc2a6a958bd33786d8e1ea
Author: Benoit TELLIER <[email protected]>
AuthorDate: Tue Oct 12 08:48:28 2021 +0700

    JAMES-3369 Email/get include inlined text in fetched properties (#685)
---
 .../rfc8621/contract/EmailGetMethodContract.scala  | 35 ++++++++++++++++++++++
 .../rfc8621/contract/EmailSetMethodContract.scala  | 30 ++++++++++++++++++-
 .../org/apache/james/jmap/mail/EmailBodyPart.scala |  6 ++--
 3 files changed, 68 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/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 8968153..47e9254 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
@@ -4108,6 +4108,16 @@ trait EmailGetMethodContract {
          |                                "size": 20,
          |                                "type": "text/plain",
          |                                "charset": "ISO-8859-1"
+         |                            },
+         |                            {
+         |                                "charset": "iso-8859-1",
+         |                                "disposition": "inline",
+         |                                "size": 19,
+         |                                "partId": "5",
+         |                                "blobId": "${messageId.serialize}_5",
+         |                                "name": "avertissement.txt",
+         |                                "type": "text/plain",
+         |                                "cid": 
"[email protected]"
          |                            }
          |                        ]
          |                    }
@@ -4173,6 +4183,16 @@ trait EmailGetMethodContract {
          |                                "size": 30,
          |                                "type": "text/html",
          |                                "charset": "ISO-8859-1"
+         |                            },
+         |                            {
+         |                                "charset": "iso-8859-1",
+         |                                "disposition": "inline",
+         |                                "size": 19,
+         |                                "partId": "5",
+         |                                "blobId": "${messageId.serialize}_5",
+         |                                "name": "avertissement.txt",
+         |                                "type": "text/plain",
+         |                                "cid": 
"[email protected]"
          |                            }
          |                        ]
          |                    }
@@ -4433,6 +4453,11 @@ trait EmailGetMethodContract {
          |                                "value": 
"/blabla/\\r\\n*bloblo*\\r\\n",
          |                                "isEncodingProblem": false,
          |                                "isTruncated": false
+         |                            },
+         |                            "5":{
+         |                                "value": "inline attachment\\r\\n",
+         |                                "isEncodingProblem": false,
+         |                                "isTruncated": false
          |                            }
          |                        }
          |                    }
@@ -4497,6 +4522,11 @@ trait EmailGetMethodContract {
          |                                "value": 
"<i>blabla</i>\\r\\n<b>bloblo</b>\\r\\n",
          |                                "isEncodingProblem": false,
          |                                "isTruncated": false
+         |                            },
+         |                            "5": {
+         |                                "value": "inline attachment\\r\\n",
+         |                                "isEncodingProblem": false,
+         |                                "isTruncated": false
          |                            }
          |                        }
          |                    }
@@ -4568,6 +4598,11 @@ trait EmailGetMethodContract {
          |                                "value": 
"<i>blabla</i>\\r\\n<b>bloblo</b>\\r\\n",
          |                                "isEncodingProblem": false,
          |                                "isTruncated": false
+         |                            },
+         |                            "5":{
+         |                                "value": "inline attachment\\r\\n",
+         |                                "isEncodingProblem": false,
+         |                                "isTruncated": false
          |                            }
          |                        }
          |                    }
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 0b05f9a..96ea9f1 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
@@ -14,7 +14,7 @@
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
- * under the License.                                           *
+ * under the License.                   *
  ****************************************************************/
 package org.apache.james.jmap.rfc8621.contract
 
@@ -2807,6 +2807,24 @@ trait EmailSetMethodContract {
            |      "size": 166,
            |      "type": "text/html",
            |      "charset": "UTF-8"
+           |    },
+           |    {
+           |        "charset": "UTF-8",
+           |        "disposition": "inline",
+           |        "size": 11,
+           |        "partId": "6",
+           |        "blobId": "${messageId}_6",
+           |        "type": "text/plain",
+           |        "cid": "abc"
+           |    },
+           |    {
+           |        "charset": "UTF-8",
+           |        "disposition": "inline",
+           |        "size": 11,
+           |        "partId": "7",
+           |        "blobId": "${messageId}_7",
+           |        "type": "text/plain",
+           |        "cid": "def"
            |    }
            |  ],
            |  "bodyValues": {
@@ -2814,6 +2832,16 @@ trait EmailSetMethodContract {
            |      "value": "$htmlBody",
            |      "isEncodingProblem": false,
            |      "isTruncated": false
+           |    },
+           |    "6": {
+           |        "value": "123456789\\r\\n",
+           |        "isEncodingProblem": false,
+           |        "isTruncated": false
+           |    },
+           |    "7": {
+           |        "value": "123456789\\r\\n",
+           |        "isEncodingProblem": false,
+           |        "isTruncated": false
            |    }
            |  }
            |}]""".stripMargin)
diff --git 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
index 09c2bb9..dc2646d 100644
--- 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
+++ 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
@@ -20,6 +20,7 @@
 package org.apache.james.jmap.mail
 
 import java.io.OutputStream
+
 import cats.implicits._
 import com.google.common.io.CountingOutputStream
 import eu.timepit.refined.api.Refined
@@ -271,8 +272,9 @@ case class EmailBodyPart(partId: PartId,
   }
 
   private val hasTextMediaType: Boolean = `type`.equals(TEXT_PLAIN) || 
`type`.equals(TEXT_HTML)
-  private val shouldBeDisplayedAsBody: Boolean = hasTextMediaType && 
disposition.isEmpty && cid.isEmpty
-  private val shouldBeDisplayedAsAttachment: Boolean = 
!shouldBeDisplayedAsBody && subParts.isEmpty
+  private val shouldBeDisplayedAsBody: Boolean = hasTextMediaType && 
!disposition.contains(Disposition.ATTACHMENT )
+  private val shouldBeDisplayedAsBodyStrict: Boolean = hasTextMediaType && 
disposition.isEmpty && cid.isEmpty
+  private val shouldBeDisplayedAsAttachment: Boolean = 
!shouldBeDisplayedAsBodyStrict && subParts.isEmpty
 
   private def textBodyOfMultipart: List[EmailBodyPart] = `type` match {
     case MULTIPART_ALTERNATIVE => getBodyParts(subParts.getOrElse(Nil), 
TEXT_PLAIN)

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

Reply via email to