Table of Contents

Method DiscardAsync

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

DiscardAsync(MailDraftId, CancellationToken)

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

public Task<MailDraftFilingResult> DiscardAsync(MailDraftId draftId, CancellationToken cancellationToken)

Parameters

draftId MailDraftId

The draft to give up.

cancellationToken CancellationToken

Cancels the write and the commands that follow it.

Returns

Task<MailDraftFilingResult>

What settling the mailbox did, which is already durable by the time it is returned.

Remarks

Only a draft this system created can be given up here. The identifier names a record MailFathom wrote, and the copies that record names are the only occurrences the removal ever reaches — so a draft the owner wrote in their own mail client is not refused by a check, it is unreachable, because nothing holds it under an identifier this method accepts.

The record is marked before anything is issued and removed once the copies are settled, so a process that dies in between leaves a draft the pass finishes rather than a message in the owner's folder that nothing can name.

A promoted draft is refused rather than given up here. Its message is a queued send that this would leave untouched, so removing the draft would answer a caller asking for the message not to exist by sending it anyway and keeping no record of where it came from. What stops such a send is cancelling the send, and until it is delivered or cancelled the draft stands — which is the same answer revising a promoted draft already gives.

Exceptions

PrincipalNotAuthorizedException

Thrown when the caller does not hold MailDraftsWrite.

MailDraftRefusedException

Thrown when no draft this deployment holds is still one to give up under that identifier.