Method ReadEmailsAsync
- Namespace
- MailFathom.Application.Emails.Threads
- Assembly
- MailFathom.Application.dll
ReadEmailsAsync(EmailThreadId, MailboxScope, CancellationToken)
Reads the emails of one conversation the caller may see, whatever readable folders they sit in.
Task<IReadOnlyList<ThreadedEmailSummary>> ReadEmailsAsync(EmailThreadId threadId, MailboxScope scope, CancellationToken cancellationToken)
Parameters
threadIdEmailThreadIdThe conversation to read, which may be one a merge has since folded into another.
scopeMailboxScopeThe accounts and folders configuration admits to tools, which the query is narrowed by.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task<IReadOnlyList<ThreadedEmailSummary>>
The conversation's messages in no particular order, at most MaximumAssembledEmails plus one, and empty when the identifier names no conversation this deployment holds.
Remarks
The one row past the bound is what tells the caller the conversation runs further, and it is read rather than inferred: a conversation holding exactly MaximumAssembledEmails messages is complete, and a reader that stopped at the bound could not tell it from one that was cut. The extra row is a signal rather than content, so the caller drops it before anything is ordered, counted, or published.
A merged conversation resolves to the one it was merged into, so a thread identifier a tool published before a merge still reaches the conversation it named instead of answering not-found.
Tombstoned messages are excluded, which is what makes a deleted message leave the thread it was in.
The scope narrows the query rather than the answer, which is what the bound above makes a correctness question instead of a preference. A conversation is threaded across every folder it reached, withheld ones included, so a bound applied before the withholding would spend its rows on mail the caller may never see and cut readable mail that sits behind it. The caller decides what a tool may read and hands that decision here, so the rows counted against the bound are the rows a caller could be shown.