Table of Contents

Class MailboxChangeSubmission

Namespace
MailFathom.Application.Mail.Mutations
Assembly
MailFathom.Application.dll

Takes one authored change in hand, choosing from the account's custody phase whether it is carried to a mail server or committed locally.

public sealed class MailboxChangeSubmission
Inheritance
MailboxChangeSubmission
Inherited Members

Remarks

This is the one place that choice is made. Every requester — a person through the client, a tool, a rule, and a spam verdict — reaches a mailbox through a use case that submits here, so none of them branches on where the mail lives: ADR 0034 requires that the executor be chosen once, in the mutation layer, from the account's phase.

On an account whose source is the truth, the change is written down as the durable record the account's convergence pass carries, exactly as before. On a held account there is no server to carry it to, so it is committed to stored state together with its audit entry, in the caller's transaction, and no record is written — a transaction either happened or it did not, and there is no sequence for a crash to interrupt. The one exception is erasure: a delete of a message already in the trash opens a record marked as the local erasure it is, held for the caller's window, so the existing withdrawal and release routes keep acting on it and the cascade runs only once the window has passed.

A restoring account commits locally for the same reason a held one does — MailFathom is still the truth until the mailbox has been appended back — and owes its source one thing more. Where the message holds an occurrence, never drained or already appended, the same transaction opens the ordinary record the converger carries under ADR 0007, so an act taken during the restore reaches the source instead of being undone by it; where the message holds none, the local commit is the whole of the act and the restore carries it when it appends the message.

A copy is the one local change that takes two phases, because it creates a second stored message with a payload of its own and a payload is placed with no transaction open across the placement. The caller places one through PrepareCopiesAsync(MailAccountId, IReadOnlyCollection<StoredEmailId>, CancellationToken) before it opens its transaction and hands it back in, which is the same shape the destination folders already take and for the same reason.

The phase is read inside the caller's transaction rather than before it, so a change and the phase it was judged under commit together.

Constructors

MailboxChangeSubmission(ILocalMailFolderStore, IMailboxMutationRecordStore, ILocalEmailStateStore, LocalMailCopier, IMailboxMutationAuditSettingsReader, IMailboxMutationAuditEntryStore, ClientSignals, TimeProvider)

Initializes the submission over both executors and what a local change is audited and announced through.

Methods

Announce(AppliedMailboxChange)

Tells the clients watching an account about a local change that has committed.

EraseAsync(IPersistenceSession, MailboxMutationRecord, CancellationToken)

Runs a held erasure whose window has passed, removing the message and everything derived from it.

PrepareCopiesAsync(MailAccountId, IReadOnlyCollection<StoredEmailId>, CancellationToken)

Places the payload of every copy a batch asks for, before the transaction that commits them opens.

SubmitAsync(IPersistenceSession, MailboxMutationRequest, MailboxDestination?, DateTimeOffset?, PreparedLocalCopy?, CancellationToken)

Records or commits one change, inside the caller's transaction, with the copy a held account would need.

SubmitAsync(IPersistenceSession, MailboxMutationRequest, MailboxDestination?, DateTimeOffset?, CancellationToken)

Records or commits one change, inside the caller's transaction.

SubmitMoveAsync(IPersistenceSession, MailboxMutationRequest, MailboxDestination, CancellationToken)

Records or commits a move a person asked for, answering one into the folder the message is in as already there.