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 written into the owner's own mailbox and reaches nobody else, 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.
Constructors
- MailDraftBook(IMailDraftStore, IEmailContentStore, OptimisticConcurrencyRetryPolicy, MailDraftFiler, AccessAuthorization, TimeProvider)
Initializes the book from the record it writes and the mailbox it keeps in step.
Methods
- DiscardAsync(MailDraftId, CancellationToken)
Gives up one draft and takes the copies of it back out of the mailbox.
- SaveAsync(MailAccountId, OutgoingEmailRequester, ComposedMailDraft, MailDraftId?, CancellationToken)
Writes a composed draft down, as a new one or as the next revision of one that already exists.