fix(attachments): download/view attachments on cross-account All-Mail messages

Blobs are scoped per JMAP account, but the attachment download/preview path
always used the active account's client and accountId. Opening a message from a
different account in the unified / All-Mail view and downloading (or previewing)
an attachment therefore 404'd against the active account.

Route the blob fetch to the message's source instead:
- resolveBlobSource() picks the owning login's client
  (getClientForAccount(sourceClientAccountId)) and the owner accountId
  (sourceAccountId) for delegated/shared blobs, in the unified view;
- handleDownloadAttachment + the attachment-preview handlers use it;
- downloadBlob / fetchBlobAsObjectUrl / fetchBlobArrayBuffer gain an accountId
  param (getBlobDownloadUrl/fetchBlob already had one).

Adds 10-attachments: an attachment on another account's All-Mail message
downloads with the correct bytes (verified to fail without the routing).
This commit is contained in:
Stefan Hildebrandt
2026-07-11 21:15:43 +02:00
parent c3acb537d0
commit 26c3d07d56
7 changed files with 161 additions and 23 deletions
+7 -1
View File
@@ -85,7 +85,9 @@ integration/
├── 05-actions.spec.ts # context-menu read/unread, delete, spam (inbox)
├── 06-shared-folders.spec.ts # delegated folder: appears + read/unread/delete/spam
├── 07-drafts.spec.ts # multiple recipients, changed sender, continue-draft button
── 08-shared-moves.spec.ts # moving mail across own/shared and shared/shared
── 08-shared-moves.spec.ts # moving mail across own/shared and shared/shared
├── 09-live-counters.spec.ts # live unified/All-Mail counters (login + shared)
└── 10-attachments.spec.ts # cross-account attachment download from All Mail
```
## Findings surfaced by the suite
@@ -110,6 +112,10 @@ because the UI behaviour is currently incomplete. Worth a look:
"Move to" submenu offers the shared folder, but clicking it is a no-op.
Shared ⇆ shared (same owner) moves work. Pinned with `test.fail` in
`08-shared-moves`.
- **Cross-account attachments (fixed).** Blobs are account-scoped, so viewing/
downloading an attachment on an All-Mail message from another account 404'd
against the active account. The download/preview path now routes to the
message's owning client + accountId (`10-attachments`).
## How the tests work