Method OpenAsync
- Namespace
- MailFathom.Application.Emails.DownloadAttachment
- Assembly
- MailFathom.Application.dll
OpenAsync(AttachmentDownloadTicket, CancellationToken)
Opens the attachment the ticket authorizes.
public Task<IOpenedEmailAttachment?> OpenAsync(AttachmentDownloadTicket ticket, CancellationToken cancellationToken)
Parameters
ticketAttachmentDownloadTicketWhat the redeemed capability authorizes.
cancellationTokenCancellationTokenCancels the read when the reader disconnects.
Returns
- Task<IOpenedEmailAttachment>
The opened attachment, which the caller owns and must dispose, or null when there is nothing to serve.
Remarks
The principal is asked for before the ticket is acted on, and it is asked for here rather than only at the route, so that an entrypoint added later cannot reach an attachment by holding a mailbox grant. A capability is the authorization in full — it names one attachment of one email and expires — which is why this use case admits that kind alone and asks for no permission beside it.
A damaged or missing local copy records a repair request before the refusal, exactly as reading the message's content does. The finding is about the stored copy rather than about who asked for it, so discarding it because the request happened to arrive through a link would leave a defect discovered and unrecorded.
Exceptions
- ArgumentNullException
Thrown when
ticketis null.- PrincipalNotAuthorizedException
Thrown when the use case was reached under anything but a capability this deployment signed.