Class EmailThreadAssembly
- Namespace
- MailFathom.Application.Emails.Threads
- Assembly
- MailFathom.Application.dll
Places one stored email in the conversation its message identifiers name.
public sealed class EmailThreadAssembly
- Inheritance
-
EmailThreadAssembly
- Inherited Members
Remarks
Membership is decided from Message-ID, In-Reply-To and References and from nothing else. A
subject is not evidence: Invoice arrives from four unrelated senders in a month, and a fallback that closed a
conversation on a normalized subject would merge exchanges that never touched. Over-linking is the failure a reader
cannot detect, because nothing in what they are shown says two halves of it were never one; under-linking is visible
and correct, so a client that drops References leaves a conversation split rather than guessed back together.
The whole placement happens inside the caller's transaction. Two callers reach it — the arrival pipeline, in the transaction that commits the message, and re-derivation, which re-reads a stored message's own MIME — and both need the placement committed with the columns it was decided from, so no message is ever readable while belonging to nothing.
It is idempotent by construction. Every step reads the state it would write and converges on it: a message assembled twice reaches the same conversation, an identifier already bound is not bound again, and a reply relation already recorded is left alone. That is what makes re-deriving a scope whose conversations are assembled change nothing.
A race between two arrivals binding one identifier for the first time is resolved by the database rather than here. Both read nothing and both bind, and the loser violates the store's uniqueness — which the retry resolves by re-reading what the winner assembled and joining it.
Constructors
- EmailThreadAssembly(IEmailThreadStore)
Initializes the assembly.
Methods
- AssembleAsync(IPersistenceSession, MailAccountId, ThreadedEmail, EmailThreadId?, CancellationToken)
Places the email, merging any conversations its identifiers prove were always one.