Skip to content

[FIX] Email/get full view: hasAttachment should filter out inlined at… #2709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chibenwa
Copy link
Contributor

@chibenwa chibenwa commented May 5, 2025

…tachment with cid

CF

private boolean hasAttachment(List<MessageAttachmentMetadata> attachments) {

curl 'https://jmap.linagora.com/oidc/jmap'   -H 'Accept-Language: en-US,en;q=0.9,fr;q=0.8'   -H 'Connection: keep-alive'   -H 'Origin: https://tmail.linagora.com'   -H 'Referer: https://tmail.linagora.com/'   -H 'Sec-Fetch-Dest: empty'   -H 'Sec-Fetch-Mode: cors'   -H 'Sec-Fetch-Site: same-site'   -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36'   -H 'accept: application/json;jmapVersion=rfc-8621'   -H 'authorization: Bearer xxxx'   -H 'content-type: application/json'   -H 'sec-ch-ua: "Chromium";v="135", "Not-A.Brand";v="8"'   -H 'sec-ch-ua-mobile: ?0'   -H 'sec-ch-ua-platform: "Linux"'   --data-raw '{"using":["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail","urn:apache:james:params:jmap:mail:shares"],"methodCalls":[["Email/get",{"accountId":"50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac","ids":["10bb6ca0-29c5-11f0-9651-fb8f0acfdec1"],"properties":["hasAttachment"],"fetchHTMLBodyValues":true},"c0"]]}' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   644  100   313  100   331    409    432 --:--:-- --:--:-- --:--:--   841
{
  "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
  "methodResponses": [
    [
      "Email/get",
      {
        "accountId": "50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac",
        "state": "13332360-29c5-11f0-9651-fb8f0acfdec1",
        "list": [
          {
            "id": "10bb6ca0-29c5-11f0-9651-fb8f0acfdec1",
            "hasAttachment": false
          }
        ],
        "notFound": []
      },
      "c0"
    ]
  ]
}

Has no attachment (normal with just one inline image)

Same call with body properties however has one.

CF

$ curl 'https://jmap.linagora.com/oidc/jmap' \
  -H 'Accept-Language: en-US,en;q=0.9,fr;q=0.8' \
  -H 'Connection: keep-alive' \
  -H 'Origin: https://tmail.linagora.com' \
  -H 'Referer: https://tmail.linagora.com/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-site' \
  -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36' \
  -H 'accept: application/json;jmapVersion=rfc-8621' \
  -H 'authorization: Bearer xxxx' \
  -H 'content-type: application/json' \
  -H 'sec-ch-ua: "Chromium";v="135", "Not-A.Brand";v="8"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  --data-raw '{"using":["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail","urn:apache:james:params:jmap:mail:shares"],"methodCalls":[["Email/get",{"accountId":"50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac","ids":["10bb6ca0-29c5-11f0-9651-fb8f0acfdec1"],"properties":["bodyValues","htmlBody","attachments","headers","keywords","mailboxIds","messageId","references","header:X-SMIME-Status:asText", "hasAttachment"],"fetchHTMLBodyValues":true},"c0"]]}' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4085  100  3625  100   460   3947    500 --:--:-- --:--:-- --:--:--  4454
{
  "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
  "methodResponses": [
    [
      "Email/get",
      {
        "accountId": "50fb9073ba109901291988b0d78e8a602a6fcd96fbde033eb46ca308779f8fac",
        "state": "13332360-29c5-11f0-9651-fb8f0acfdec1",
        "list": [
          {
            "id": "10bb6ca0-29c5-11f0-9651-fb8f0acfdec1",
            "keywords": {
              "$seen": true
            },
            "mailboxIds": {
              "679397f0-edde-11ea-b4a0-bbb288e57c64": true
            },
            "headers": [
              {
                "name": "Return-Path",
                "value": " <[email protected]>"
              },
              {
                "name": "org.apache.james.rspamd.flag",
                "value": " NO"
              },
              {
                "name": "org.apache.james.rspamd.status",
                "value": " No, actions=no action score=0.0 requiredScore=15.0"
              },
              {
                "name": "Delivered-To",
                "value": " [email protected]"
              },
              {
                "name": "Received",
                "value": " from 172.17.0.1 (EHLO incoming.linagora.com) ([172.17.0.1])\r\n          by incoming.linagora.com (JAMES SMTP Server ) with ESMTP ID 445c6e32\r\n          for <[email protected]>;\r\n          Mon, 05 May 2025 15:24:40 +0000 (UTC)"
              },
              {
                "name": "Received",
                "value": " from smtp.linagora.com (smtp.linagora.com [54.36.8.78])\r\n\tby incoming.linagora.com (Postfix) with ESMTPS id 6DE3D14058D\r\n\tfor <[email protected]>; Mon,  5 May 2025 15:24:40 +0000 (UTC)"
              },
              {
                "name": "Received",
                "value": " from ?Open?PaaS?SMTP?server?for?Linagora? (imap.linagora.com [51.75.13.34])\r\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\r\n\t(No client certificate requested)\r\n\tby smtp.linagora.com (Postfix) with ESMTPSA id 1C27FEE231\r\n\tfor <[email protected]>; Mon,  5 May 2025 17:31:36 +0200 (CEST)"
              },
              {
                "name": "MIME-Version",
                "value": " 1.0"
              },
              {
                "name": "Subject",
                "value": " test"
              },
              {
                "name": "X-LINAGORA-Copy-Delivery-Done",
                "value": " 1"
              },
              {
                "name": "From",
                "value": " Benoit TELLIER <[email protected]>"
              },
              {
                "name": "To",
                "value": " =?ISO-8859-1?Q?Beno=EEt_TELLIER?= <[email protected]>"
              },
              {
                "name": "Reply-To",
                "value": " [email protected]"
              },
              {
                "name": "Date",
                "value": " Mon, 5 May 2025 15:24:38 +0000"
              },
              {
                "name": "Message-ID",
                "value": " <[email protected]>"
              },
              {
                "name": "User-Agent",
                "value": " Twake-Mail/0.15.3 Mozilla/5.0 (X11; Linux x86_64)\r\n AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"
              },
              {
                "name": "Content-Type",
                "value": " multipart/related;\r\n boundary=\"-=Part.11e.63bce76e5658129d.196a10c968b.61646b529c1283dd=-\""
              }
            ],
            "messageId": [
              "[email protected]"
            ],
            "references": null,
            "htmlBody": [
              {
                "partId": "4",
                "blobId": "10bb6ca0-29c5-11f0-9651-fb8f0acfdec1_4",
                "size": 719,
                "type": "text/html",
                "charset": "UTF-8",
                "language": [
                  "en-US"
                ]
              }
            ],
            "attachments": [
              {
                "partId": "5",
                "blobId": "10bb6ca0-29c5-11f0-9651-fb8f0acfdec1_5",
                "size": 35196,
                "name": "JMAP-V2-1400x500-copy_puUEqKS.png",
                "type": "image/png",
                "charset": "base64",
                "disposition": "inline",
                "cid": "0d3971d0-29c5-11f0-8144-a189362d1cb8"
              }
            ],
            "bodyValues": {
              "4": {
                "value": "<div><br></div><div><img src=\"cid:0d3971d0-29c5-11f0-8144-a189362d1cb8\" alt=\"JMAP-V2-1400x500-copy_puUEqKS\" style=\"max-width:1650px;\" data-mimetype=\"image/png\"></div><div><br><br><br></div><div class=\"tmail-signature\"><span class=\"tmail_signature_prefix\">--&nbsp;</span><br><br>Best regards,<br><br><b>Benoit TELLIER</b><br><br>General manager of <a href=\"https://linagora.vn\">Linagora VIETNAM</a>.<br>Product owner for <a href=\"https://github.com/linagora/tmail-flutter\">Team-Mail</a> product.<br>Chairman of the <a href=\"https://james.apache.org/\">Apache James project</a>.<br><br>Mail: <a href=\"mailto:[email protected]\">[email protected]</a><br>Tel: (0033) 6 77 26 04 58 (WhatsApp, Signal)<br><br><br></div>",
                "isEncodingProblem": false,
                "isTruncated": false
              }
            },
            "hasAttachment": true,
            "header:X-SMIME-Status:asText": null
          }
        ],
        "notFound": []
      },
      "c0"
    ]
  ]
}

Please @quantranhong1999 help me make this contribution land...

@quantranhong1999 quantranhong1999 marked this pull request as ready for review May 6, 2025 03:28
Copy link
Contributor Author

@chibenwa chibenwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Thanks for the follow up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants