Table of Contents

Method ReadableScopeAsync

Namespace
MailFathom.Application.Emails.Mailboxes
Assembly
MailFathom.Application.dll

ReadableScopeAsync(IReadOnlyList<MailAccountSelector>, IReadOnlyList<MailFolderReference>, JunkMailInclusion, CancellationToken)

Resolves what a request named into the scope a query runs with.

public Task<MailboxScope> ReadableScopeAsync(IReadOnlyList<MailAccountSelector> accountSelectors, IReadOnlyList<MailFolderReference> folders, JunkMailInclusion junkMail, CancellationToken cancellationToken)

Parameters

accountSelectors IReadOnlyList<MailAccountSelector>

The text a request named accounts with, or empty for every account the caller's user is assigned.

folders IReadOnlyList<MailFolderReference>

The folders a request named, each by alias or by role, or empty for every folder.

junkMail JunkMailInclusion

Whether the caller asked for the account's junk folder, which defaults to it being left out.

cancellationToken CancellationToken

Cancels the reads of which folders the accounts in scope admit.

Returns

Task<MailboxScope>

The scope a query runs with.

Remarks

An account may be named by the identifier the deployment generated for it or by the display name it is published under, and this is where the two become one identity. Resolution happens against the accounts the caller's user is assigned rather than at a protocol boundary, so text naming nothing is refused by the same rule and with the same failure as an identifier the deployment stopped serving and as one belonging to somebody else — a caller cannot learn from the refusal which of the three it was holding, so a refusal enumerates neither spellings nor other users' mailboxes.

An account the caller's user is not assigned is refused before anything is read, rather than narrowed away by a predicate: a narrowed predicate would answer with an empty result, and an empty result tells a caller that the name they used exists. The resolved identities are what the scope is built from, so the same account named two ways is one query with one continuation cursor.

A request that names no account is restricted to the accounts the user is assigned rather than left unrestricted. Two separate things make that necessary: removing an account from configuration leaves its stored rows in place, so an absent account predicate would keep publishing mail from an account this deployment no longer serves, and the rows of every other user are in the same table. A user assigned nothing therefore resolves to NothingReadable rather than to a scope carrying an empty account list: the account containment is composed unconditionally, so an empty list admits no row, but such a scope would still carry the deployment's folder decisions and read as a scope over every mailbox's folders. Leaving early is what keeps the two apart. The resolved accounts, not the requested ones, take part in a continuation cursor's fingerprint.

The folders a tool may read are named here, once, rather than by each read model — which is what makes "no tool lists, searches, reads, or answers from it" a property of the system instead of a list of places somebody has to keep complete. It is stated as what is admitted rather than as what is withheld, because the store holds rows of folders configuration no longer names and no list of withheld names reaches those: a folder nobody mapped is a folder MailFathom does not have, and it stays out by not being admitted. A tool that read the mailbox some other way would bypass this, which is why the two reads that reach an email by its identifier ask the folder mapping directly rather than building a scope. Until #2330 moves them, those two read the mapping in the settings the work's own scope was prepared with while a scope reads the account's settings columns. A request's settings come from the user this replica holds, which it brings to the committed version within one convergence interval — at once on the replica that wrote it, and sooner wherever the announcement arrives — so for that long a folder a write withheld can stay readable by identifier while it is already out of every scope.

The junk folder is withheld here too, and it is a different kind of decision from the one above: an operator did not withhold it, the default did, and a caller may ask for it back. Resolving both in one place is what keeps the override from being able to reveal a folder the operator withheld — a folder that is hidden *and* junk stays out under either answer, because the two lists narrow the query independently.

A folder named by the role it plays is turned into the folder of each account it means here, after the accounts are settled and before anything is read, because a role means a different folder on each account in scope. One role therefore narrows a multi-account read to each account's own folder rather than to whichever alias one deployment happened to choose. A role no account in scope maps is refused instead of narrowed away, for the reason an unserved account is: the caller asked for a folder that is not there, and an empty page would read as a folder holding no mail. Naming role:Junk is narrowing rather than asking — the withholding above still applies, so a read that names it and does not also ask for junk mail returns nothing.

Exceptions

PrincipalNotAuthorizedException

Thrown when the work in hand is acting for no user, which the deployment administrator and this process's own identity both are.

MailboxQueryFilterInvalidException

Thrown when either list names more values than its limit permits.

MailAccountNotAccessibleException

Thrown when the request names an account the caller's user is not assigned, which includes every account this deployment does not serve.

MailFolderRoleUnmappedException

Thrown when the request names a role no account in scope maps a folder with.

ArgumentOutOfRangeException

Thrown when junkMail is not a defined member.