Method DiscardAsync
- Namespace
- MailFathom.Application.Mail.Delivery.Drafts
- Assembly
- MailFathom.Application.dll
DiscardAsync(MailDraftId, UserId, CancellationToken)
Gives up one draft and takes the copies of it back out of the mailbox.
public Task<MailDraftFilingResult> DiscardAsync(MailDraftId draftId, UserId writtenBy, CancellationToken cancellationToken)
Parameters
draftIdMailDraftIdThe draft to give up.
writtenByUserIdThe user giving it up, who has to be the one the draft was written by.
cancellationTokenCancellationTokenCancels 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 user 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 user'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.
A draft somebody else wrote is refused as one nobody holds, the same answer and for the same reason revising one gives: ADR 0014 keeps a draft on its author rather than on the mailbox, so once two people are assigned one account the account no longer says whose draft it is, and telling a foreign draft apart from an absent one would let a caller learn which drafts exist by asking to give them up. The author is asked here rather than left to whichever collaborator a caller was wired to.
Exceptions
- PrincipalNotAuthorizedException
Thrown when the caller does not hold MailDraftsWrite.
- MailDraftRefusedException
Thrown when no draft this deployment holds is still one for
writtenByto give up under that identifier.