Table of Contents

Constructor OutgoingMailCancellation

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

OutgoingMailCancellation(OutgoingMailReader, IOutboxOperationStore, AccessAuthorization)

Withdraws a send the caller queued, while there is still a window in which withdrawing one means anything.

public OutgoingMailCancellation(OutgoingMailReader reader, IOutboxOperationStore outbox, AccessAuthorization authorization)

Parameters

reader OutgoingMailReader

Decides which send this caller may act on at all, in the one place that is decided.

outbox IOutboxOperationStore

Performs the conditional withdrawal, and reports what stopped it where it wrote nothing.

authorization AccessAuthorization

Answers whether the caller holds the grant that lets it send.

Remarks

This is the only point at which sending is reversible at all. Between the record being written and the first byte of the body going out there is a window — seconds ordinarily, longer where an operator configured a hold — and a caller that has just realized it queued the wrong thing can close it. Past that the message is somebody else's and the answer says so plainly rather than reporting a withdrawal that did not happen.

The withdrawal itself is one statement and this is a second authorization over it rather than a second implementation of it. CancelAsync(OutgoingEmailId, CancellationToken) decides and writes in one statement, conditioned on the same facts a claim is conditioned on, so a send an attempt is holding is left alone instead of being cancelled out from under a session that may be part-way through an envelope. A second statement written here would be two accounts of one invariant, and whichever drifted would be found as a message somebody was told had been withdrawn. What differs between the two callers is who may ask and about which records: an operator holds AdminOperate and may name any send this deployment holds, while a caller here holds MailSend and reaches only what it queued.

Withdrawing a send twice is one withdrawal. A record already at Cancelled is answered with itself and nothing is written, which is what makes the tool over it honestly idempotent rather than idempotent as long as nobody repeats a call.