linagora / tmail-backend

GNU Affero General Public License v3.0
39 stars 21 forks source link

[PublicAsset] PublicAsset/set create JMAP method #1048

Closed Arsnael closed 4 months ago

Arsnael commented 4 months ago

The /set create JMAP method for PublicAsset takes following fields as request:

The blobId needs to refer to a blob that has been previously uploaded in the upload bucket via the jmap upload route. We need to check that the blob exists, need to copy the content into the bucket for public assets and validate that the content is an image.

Request:

{
  "using": ["urn:ietf:params:jmap:core", "com:linagora:params:public:assets"],
  "methodCalls": [
    [
      "PublicAsset/set", {
        "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
        "create": {
          "4f29": {
            "blobId": "1234",
            "identityIds": ["12", "34"]
          }
        }
      }, "0"
    ]
  ]
}

Response:

{
  "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
  "methodResponses": [
    ["PublicAsset/set", {
      "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
      "newState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
      "created": {
        "4f29": {
          "id": "123456",
          "publicURI": "http://jmap/accountid/assetid",
          "size": 65432
        }
      }
    }, "0"]
  ]
}

DoD: integration tests

chibenwa commented 4 months ago

identityIds need to be validated

vttranlina commented 4 months ago

draft pr https://github.com/linagora/tmail-backend/pull/1057