Table of Contents

Class LocalMailCopier

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

Writes the second stored message a copy on a held account produces.

public sealed class LocalMailCopier
Inheritance
LocalMailCopier
Inherited Members

Remarks

A copy is the one local act that creates mail rather than changing it, so it is the one that cannot be a single write inside the caller's transaction: ADR 0008 makes the copy a second stored message with a payload of its own, and ADR 0017 refuses to share one payload between two rows, while a payload has to be placed with no transaction open across the placement. The act is therefore two-phase, exactly as filing a draft or a sent copy is: PrepareAsync(MailAccountId, StoredEmailId, CancellationToken) reads the message and places its payload before the transaction, and CommitAsync(IPersistenceSession, PreparedLocalCopy, MailFolderResolutionId, LocalMailFolderId, CopiedMailFlags, CancellationToken) writes the row, points it at the placed payload, and files it, inside the transaction the change commits in.

Nothing is carried across from the source row but the flags and the keywords the caller supplies. The metadata, the search document, and the conversation are derived again from the payload, which is what ADR 0008 says a copy is: two local messages that happen to share their content, each deriving its own.

A copy placed and never committed leaves an object nothing points at. That is the direction the two phases are ordered in deliberately — the reverse would be a row naming a payload that was never placed — and the content reclamation pass takes such an object exactly as it takes one a rolled-back transaction left.

Constructors

LocalMailCopier(IEmailMetadataRepository, IEmailContentStore, IEmailMimeReader, ILocalMailFolderStore)

Initializes the copier over the stores a copied message is written through.

Methods

CommitAsync(IPersistenceSession, PreparedLocalCopy, MailFolderResolutionId, LocalMailFolderId, CopiedMailFlags, CancellationToken)

Writes a prepared copy as a stored message of its own, inside the transaction the copy commits in.

PrepareAsync(MailAccountId, StoredEmailId, CancellationToken)

Reads a message and places the payload its copy will carry, before the transaction that commits the copy.