Table of Contents

Class MailDraftBook

Namespace
MailFathom.Application.Mail.Delivery.Drafts
Assembly
MailFathom.Application.dll

Holds every draft this deployment keeps, and is the one way one is written, revised, or given up.

public sealed class MailDraftBook
Inheritance
MailDraftBook
Inherited Members

Remarks

It is the drafts' counterpart of MailOutbox and exists for the same reason: the record and the message are one decision. A draft whose message was never stored describes a revision nothing can append or promote, and a message stored under no draft is bytes nothing will ever read — so both cross one transaction here, and a crash between them leaves neither rather than half of a draft.

Being the one way in is also what makes it the place the grant is asked for. A draft is what one person is writing and has not sent, so it is admitted under the grant that says exactly that: a caller holding MailDraftsWrite for a command, and MailFathom's own identity for a rule. That is asked with no transport in the picture, so a second entrypoint added later meets it whatever it did first. What it deliberately is not is MailSend: a caller that may draft and may not send is the arrangement the two grants exist to make possible, and what stands between a draft and a recipient is the promotion, which asks for the sending grant on its own.

The mailbox is brought into step once the write has committed, and never before it. A crash in between leaves a draft the pass will settle; a crash the other way round would leave a message in somebody's drafts folder that nothing here can name.

The author term bounds the draft record and the three acts on it, not the message the mailbox holds. ADR 0014 keeps the author beside the account so a draft is read, revised, discarded, and promoted by its author alone among the account's assigned users, and that is what is enforced here. What the filer then puts into the account's drafts folder is the mailbox's own mail: a folder read and a message read narrow by assigned accounts and carry no author term, so on a mailbox assigned to more than one user the others meet the unsent revision there exactly as they meet every other message the mailbox holds. Withholding the copy instead would take the draft out of the mail client the person is writing in, which is the whole reason it is filed, and would buy a confidentiality a shared mailbox offers nowhere else.

Constructors

MailDraftBook(IMailDraftStore, IEmailContentStore, OptimisticConcurrencyRetryPolicy, MailDraftFiler, OutgoingMailScreening, AccessAuthorization, TimeProvider)

Initializes the book from the record it writes and the mailbox it keeps in step.

Methods

DiscardAsync(MailDraftId, UserId, CancellationToken)

Gives up one draft and takes the copies of it back out of the mailbox.

ReadStagedAttachmentsAsync(MailAccountId, UserId, MailDraftId?, CancellationToken)

Reads the files staged against the draft a revision replaces, so the new revision carries them too.

SaveAsync(MailAccountId, UserId, OutgoingEmailRequester, ComposedMailDraft, MailDraftId?, CancellationToken)

Writes a composed draft down, as a new one or as the next revision of one that already exists.