Be somewhere a phone can share to
ihasmail could hand a file to the share sheet as of #306, and was still not in it. Share a photo from the gallery, a link from the browser or a document from a file manager and ihasmail was not among the places it could go, which is the one piece of operating-system integration a mail app is expected to have. A share is a POST that navigates, and there is nothing on this side that can answer one: the app is a client-side router with no endpoint at that address, and the server behind it would need a route that understood the composer. So the service worker intercepts it, takes the form body, puts the files and text in its cache, and redirects to the app -- which finds them on start and opens a draft holding them. The subject is the shared title, the text and the link become the body, and files are attached and begin uploading. Nothing is addressed: a share says what to send, never who to. The body is pushed in above the signature rather than passed to open(), because open() only fits a signature when it is given no body at all -- the obvious version drops the signature from every message that started as a share, and nothing about the draft looks wrong afterwards. Collected on every start rather than when the launch URL says so. A share to a signed-out ihasmail lands on the sign-in page, and there is no account to attach to until it is done, so the payload has to outlive a redirect and a login -- which the query string does not. What that costs is a stash nobody came back for, so it carries a timestamp and expires after ten minutes. `accept` names wildcard families and explicit types and extensions both. A mail client attaches anything, but wildcards are not in the specification and operating systems differ over which form they match on, so the explicit list is what holds if the families are ignored. The cache name the worker and the app have to agree on now has one home on the app side. It was written out twice, and a drift would not fail -- a push verification would simply never complete and a share would arrive at an empty composer. One case is deliberately left to fail loudly: an app still installed whose worker has been cleared away POSTs to the server, which answers 405. A server route would trade a plain error for a silent nothing, and the payload is gone in both -- it only ever existed in that request body. Verified by test, not on a device: Android is the only place this exists at all, and the extension driving Chrome is not connected here. The handoff is pinned from the tab's side against a cache shaped exactly as the worker leaves it, since the two files never see each other.
This commit is contained in:
+14
@@ -1155,6 +1155,20 @@ needed nothing in either half.
|
||||
an inbox holding forty. The next tab to open writes the real count over it.
|
||||
Unsupported browsers show nothing, as does iOS until notification permission
|
||||
has been granted, which is that platform's condition for a badge.
|
||||
- **In the share sheet** — share a photo, a link or a file from any other app
|
||||
and ihasmail is one of the places it can go, opening a draft that holds it.
|
||||
The subject comes from the shared title, the text and the link become the
|
||||
body above your signature, and files are attached and start uploading. It
|
||||
addresses nothing: a share says what to send, never who to.
|
||||
|
||||
A share is a POST, which is not something a client-side router can answer, so
|
||||
the service worker takes the body, leaves it where a tab can collect it and
|
||||
redirects to the app. That indirection is also what lets a share to a
|
||||
signed-out ihasmail work — it waits through the sign-in page and opens after,
|
||||
which the query string could not have survived. One nobody comes back for
|
||||
expires after ten minutes rather than opening a composer full of a forgotten
|
||||
photo the next time you look. Android and Chromium only; iOS does not
|
||||
implement share targets.
|
||||
- **Share** — a message, or one attachment, handed to the operating system's
|
||||
share sheet instead of to the filesystem. On a phone a download is close to a
|
||||
dead end: the file lands in Downloads and whoever wanted to send it somewhere
|
||||
|
||||
Reference in New Issue
Block a user