On Fri, Nov 13, 2015, at 08:35 AM, Tfe Server wrote:
> I am reading the MozActivity API, and i didn't find the way to open an
> external editor, and fetch the result when done.
> 
> The goal is to open a MozActivity with a blob, and get the result to save
> it to a cloud storage.

Activities can only pass Blob and File objects, both of which are
immutable[1][2].  An editor activity would need to have the idiom that a
Blob/File is passed as part of the data payload, and that the servicing
activity specifies returnValue: true (see
https://developer.mozilla.org/en-US/docs/Web/API/Web_Activities#Activity_handler_description)
and actually returns the new/updated Blob.

If you want to pursue this, I would suggest creating a new very-explicit
activity "editBlobReturningModifiedBlob" with these semantics.  I'd also
suggest very explicitly defining how "not changed" should be expressed
since it's not immediately clear to me that object identity (AKA
sentBlob === receivedBlob) would hold if the same blob is returned
unchanged.  I'd suggest returning success with a null returned Blob
instead of overloading failure to convey no changes desired.  I'd also
suggest proposing the convention on this list and then documenting it in
the web activities MDN page once sufficient consensus is established.

Josh mentions the "open" activity, but its current semantics are already
1) very ambiguous/inconsistent and 2) likely effectively set in stone
forever.  If we undertake changes to "open" going forward before web
activities are completely deprecated and replaced by something better,
it wouldn't surprise me if we ended up creating a new, better defined
activity.

Andrew

1: DeviceStorage-provided File instances are actually somewhat more
nuanced than this.  My fuzzy recollection is that the File reference you
retrieve appears immutable because it holds a file descriptor to the
underlying file on disk, which on linux, will continue to exist even if
someone else removes/replaces the file via DeviceStorage.  But if the
recipient of the File figures out the path of the File on DeviceStorage
and has DeviceStorage access itself, it can update the file on disk,
which as far as a user can tell, means the file has been mutated.

2: Josh mentions passing FileHandle, which does allow mutation.  But as
noted, StructuredClone does not currently allow it.
_______________________________________________
dev-fxos mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-fxos

Reply via email to