Table of Contents

Method PromoteAsync

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

PromoteAsync(MailDraftId, CancellationToken)

Queues one draft for delivery, or refuses it naming what stopped it.

public Task<OutgoingEmailRecord> PromoteAsync(MailDraftId draftId, CancellationToken cancellationToken)

Parameters

draftId MailDraftId

The draft to send.

cancellationToken CancellationToken

Cancels the reads and the write.

Returns

Task<OutgoingEmailRecord>

The durable record the message was written down as.

Remarks

A draft that has already been promoted answers with the record its promotion wrote rather than writing a second one, so a caller that asked again queues one message. That read is what answers a caller whose first answer never reached it, and it settles nothing about two callers arriving together: both would find the draft unpromoted, because a read cannot see a write that has not happened yet.

It answers that way while the draft is being given up as well, which is the state a successful promotion leads to rather than an exception to it: delivery is what discards a promoted draft, and the copy leaves the folder over a network round trip after the mark is written. A retry crossing that window is asking about a message that was sent, so it is told which record carries it; only a draft this deployment holds nothing for, or one given up without ever having been sent, is refused as not found.

What settles that is the request's own identity, which is why this takes no key from whoever asked. A draft is promoted once, so the draft is the act — two callers promoting one draft compose one identity, the outbox answers the second with the record the first opened, and the two of them then write that same record onto the draft. A key somebody supplied would make the two asks two requests and put the message in the recipient's mailbox twice, which nothing downstream can withdraw.

Exceptions

PrincipalNotAuthorizedException

Thrown when the caller does not hold MailSend.

MailDraftRefusedException

Thrown when no draft is held under that identifier, when the draft names nobody to send it to, or when the stored message exceeds what this deployment sends.

OutgoingMailRefusedException

Thrown when sending is not enabled for the account, a recipient is one the recipient policy refuses, or the period has reached a ceiling.