linagora / jmap-client-ts

JMAP 1.0 client library in TypeScript
MIT License
39 stars 16 forks source link

Transferring uploaded attachment between draft versions #55

Closed jeserkin closed 3 years ago

jeserkin commented 3 years ago

Problem: When uploading Blob and then attaching to email with Email/set it provides attachment with new ID, that is related to email object. e.g. Email -> blobId: 'XXXXX', then attachment in that email will be e.g. partId: '5', blobId: 'XXXXX_5'.

When creating new email version (e.g. sender changed email subject), then it will not be created if I pass same list of attachments with it. I assume, that issue is that new version will have e.g. blobId: 'YYYYY' and it has no information about blobId: 'XXXXX'. Therefore it will not be able to get attachment, that has blobId: 'XXXXX_5'.

Expected behaviour: Version 1 - it can find attachment by ID and copy it with new id, that will be linked to new Email version. (Version is based on the ability to copy attachment between accounts - https://jmap.io/spec-core.html#blobcopy) Version 2 - it can provide original attachment id (the one, that is received in response of blob upload), so that it can be provided for new email version

NB!! Might be James and not JMAP related issue. Might be both.

jeserkin commented 3 years ago

@chibenwa I assume you are most capable to clarify this and tell whether issue is in correct project or not and whether it is an issue at all or maybe there is some undocumented functionality, that can be used to solve it.

chibenwa commented 3 years ago

Benoit Tallandier is another Benoit. Me it is @chibenwa Benoit Tellier.

Looks like a fixed issue. Now Email/set create uses the BlobResolver and should be able to access any binary content exposed as a donload.

However Email/set create will alter the id and blobId of the attachement (as it copies it it should store and expose the copied ones.)

https://jmap.io/spec-core.html#blobcopy is not implemented, multi account management is not implemented.

Version 2 - it can provide original attachment id (the one, that is received in response of blob upload), so that it can be provided for new email version

If you are the uploader. Otherwize use the blobIds returned by Email/get.

Please note that attachments are not top level entities in JMAP, hence they are attached to an Email and their lifecycle is linked to the one of emails. Destroy an email to quickly and you cannot access it's attachments any longer.

jeserkin commented 3 years ago

Thank you. This was resolved.