Table of Contents

Class EmailAttachmentDownloadReader

Namespace
MailFathom.Application.Emails.DownloadAttachment
Assembly
MailFathom.Application.dll

Opens one attachment of one stored email, from the local mailbox copy.

public sealed class EmailAttachmentDownloadReader
Inheritance
EmailAttachmentDownloadReader
Inherited Members

Remarks

Two callers reach it and each states its own authorization, because the two ways an attachment is asked for are genuinely different acts. OpenAsync(AttachmentDownloadTicket, CancellationToken) serves a link this deployment signed, which names the attachment and is the whole of the access control. OpenForReaderAsync(StoredEmailId, int, CancellationToken) serves a caller that authenticated and holds MailRead, which is a person opening a file in their own mailbox. What neither of them may do is decide the rest: everything an authorization cannot establish — that the email exists, that it belongs to an account this deployment currently serves and this user owns, that the stored copy is what was written, and that the message really carries a part at that position — is settled here for both, once.

It resolves through the live store on every request rather than against anything staged when a link was minted. An attachment is mail content in full and inherits every retention, access, and erasure constraint of the message it belongs to, so a link must not be able to outlive the deletion of its own message — which is a property of reading it afresh rather than a rule anybody has to remember.

Every refusal about what is there is the same refusal. A message this deployment no longer serves, one belonging to somebody else, a stored copy that has gone missing, a damaged one, and a position the message does not have all answer NothingToServe(), because telling them apart would let a caller learn what became of mail they cannot read — and, on the signed path, learn it while holding nothing but a URL.

A screened file is the one refusal that says so, and ScreenedOut() is how. It is not the answer above, because the caller has already been told by the read that offered them the file that the attachment exists and what it is called: what is left to withhold is what is in it, which that answer withholds entirely. AttachmentDownloadScreened holds the reasoning both ways round.

It reaches no mail server, for the reason the content read does not: the use case holds no mailbox port, so a download cannot fetch a message and cannot set the remote \Seen flag.

The screen is here rather than at either route, for the reason every check above is: a deployment that redacts what a read publishes and serves the unredacted original beside it is not a screened deployment, and one rule in one place is what stops the two endpoints from each having to remember. What it screens is the attachment's own extracted text, read afresh — nothing here depends on what a derived pass stored or on the message having been read yet. It does depend on the format set the extractor is configured with, which an operator writes for the search stage: a format excluded there is read out of nothing, and a file whose text nobody established is refused rather than served.

What decides whether the screen runs at all is SensitiveContent:ScreenOutgoingMailFor, the same key that decides whether a send is screened, read through the posture of the account the mail is in before an attachment is opened. So the asymmetry this closes is closed exactly where that key names a scanner: a deployment that wrote an empty list keeps its scanners redacting every read and serves every attachment whole, which is a deliberate configuration rather than a gap here — but it is the same shape as the one above, and an operator writing that list is deciding about downloads as well as about sends.

Nothing is redacted, because there is nothing a redaction could honestly do to a byte stream: replacing a region inside one produces a file its author never composed and whose reader has no way of knowing it was changed. So the download is refused whole, and no partial stream is ever written.

Constructors

EmailAttachmentDownloadReader(IStoredEmailSummaryReader, IEmailContentStore, IEmailAttachmentContentReader, IEmailContentRepairRequestStore, IAttachmentTextExtractor, SensitiveContentEgressScreen, MailboxScopeResolver, AccessAuthorization)

Initializes the use case.

Methods

OpenAsync(AttachmentDownloadTicket, CancellationToken)

Opens the attachment the ticket authorizes.

OpenForReaderAsync(StoredEmailId, int, CancellationToken)

Opens one attachment for a caller that authenticated and holds the mailbox read grant.