Open Bug 1669831 Opened 4 years ago Updated 1 year ago

compose.ComposeAttachment should contain a cloudFile status

Categories

(Thunderbird :: Add-Ons: Extensions API, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: je, Unassigned, NeedInfo)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

  1. Add an attachment to a message
  2. Get the attachment's properties, eg via compose.listAttachments
  3. Upload the attachment to a Filelink provider (which triggers events of the cloudFile API).
  4. Get the attachment's properties again

Actual results:

The properties of the attachment are identical before and after the upload.

Expected results:

It should be possible to determine, if an attachment has been uploaded to a Filelink provider.

Suggestion: Add a cloudFileStatus property to the compose.ComposeAttachment type. It should have 5 states:

  1. local (or regular or normal) for an attachment not handled by cloudFile
  2. uploaded after a successful upload
  3. uploading, if a cloudFile.onFileUpload event is pendig for this attachment
  4. aborting, if a cloudFile.onFileUploadAbort event is pendig for this attachment
  5. deleting, if a cloudFile.onFileDeleted event is pending for this attachment

An additional property might be useful that contains points to the cloudFile account that's handling this attachment. It could be 0, undefined or null if cloudFileStatus==local and contain the accountId otherwise.

This sounds reasonable and necessary to me.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
See Also: → 1669897
See Also: → 1669829

Geoff, fyi, this sounds like a reasonable and well-thought-out proposal to me. Reporter filed a cluster of related bugs which I linked up in see also, and you've commented on Bug 1669829 Comment 3.

Flags: needinfo?(geoff)

IIRC progress data is not internally available either.

Priority: P2 → --

(In reply to Magnus Melin [:mkmelin] from comment #3)

IIRC progress data is not internally available either.

Do you mean uplaod progess? That's because the API doesn't define a way for a Filelik provider to inform Thunderbird about its progress. See the documentation of the cloudfile API.

Correct.

This is especially bad in Thunderbird 82+ which explicitly allows Addons to modify attachments in an on BeforeSend handler. But the modified attachment is ignored because it is not uploaded again or sent with the message.

See Also: → 1662015
Flags: needinfo?(geoff)

Maybe instead of a state variable it could be implemented as an isCloudfile() function that returns a Promise? It would resolves to false for a regular attachment and to true after the pending cloudFile events for this attachment are handled. It would basically reproduce the state of the icon in the attachment pane (after bug 1667652 is fixed), not resolving while the spinner is there.

What should ComposeAttachment.getFile()do for an uploaded CloudFile attachment?

  • Return the file that was originally uploaded? Is that guaranteed to be identical to the file on the server?
  • Fetch the file via the url that cloudFile.onFileUpload returned? Timing?
  • Return null or some other kind of error?

(In reply to Johannes Endres from comment #7)

Maybe instead of a state variable it could be implemented as an isCloudfile() function that returns a Promise? It would resolves to false for a regular attachment and to true after the pending cloudFile events for this attachment are handled. It would basically reproduce the state of the icon in the attachment pane (after bug 1667652 is fixed), not resolving while the spinner is there.

Or reduce to three states: (local, uploaded, neither) with the third state returned while the spinner is spinning.

Flags: needinfo?(john)

(In reply to Johannes Endres from comment #6)

This is especially bad in Thunderbird 82+ which explicitly allows Addons to modify attachments in an on BeforeSend handler. But the modified attachment is ignored because it is not uploaded again or sent with the message.

This has been fixed by bug 1669829.

(In reply to Johannes Endres from comment #7)

Maybe instead of a state variable it could be implemented as an isCloudfile() function that returns a Promise? It would resolves to false for a regular attachment and to true after the pending cloudFile events for this attachment are handled. It would basically reproduce the state of the icon in the attachment pane (after bug 1667652 is fixed), not resolving while the spinner is there.

I was planing to expose the cloudFile account ID as part of the ComposeAttachment type. If it is not specified, it is a "local" attachment. At a later time, there will be more things one could do with the cloudFile account IDs, like converting attachments to/from/between cloudFile accounts.

(In reply to Johannes Endres from comment #8)

What should ComposeAttachment.getFile()do for an uploaded CloudFile attachment?

  • Return the file that was originally uploaded? Is that guaranteed to be identical to the file on the server?
  • Fetch the file via the url that cloudFile.onFileUpload returned? Timing?
  • Return null or some other kind of error?

It returns the original file stored in the attachment (it is still "there" while composing or saving it as a draft, only during send it gets removed). The cloudFile provider should never change the file behind a link, to not invalidate attachments/links in already send messages. Manually replacing files on the server, which have been uploaded by the cloudFile provider, is a very bad idea and I do not want to add code to actually support such thing. So adding a fetch to download the file from the server each time the attachment is requested is not something I want to add. Do you agree?

(In reply to Johannes Endres from comment #9)

Or reduce to three states: (local, uploaded, neither) with the third state returned while the spinner is spinning.

Hm, a file being uploaded is still considered local. Only after the upload finished and succeeded, its metadata is updated to represent a cloudFile. What use case do you have in mind, where the uploading state could be of interest?

You need to log in before you can comment on or make changes to this bug.