Table of Contents

Class ContactBook

Namespace
MailFathom.Application.Contacts
Assembly
MailFathom.Application.dll

The acts a contact book supports: read it — a page of it, one person, or whoever holds an address — record a person, amend one, promote one, erase one or a mailbox's whole collected book, and export one.

public sealed class ContactBook
Inheritance
ContactBook
Inherited Members

Remarks

Every surface over the books — the administration tool, the MCP tools, and collection from arriving mail — performs these acts and no others, which is what keeps the origin rule from being a convention each of them remembers. A writer names the origin it acts under, and a contact is amendable only by a writer of its own: collection never touches what a user wrote down, and a user promotes a collected contact rather than editing it in place. Promotion names the writer for the same reason, so the act of taking a record on is the user's rather than something collection can perform on its own behalf.

There are two kinds of book and each act says which it acts on. A user holds the people they wrote down; a mail account holds the people its mail says it corresponds with, once, however many users are assigned that mailbox. So a read is stated over a ContactBookScope — one user's own book and the collected book of each account they are assigned — and a write is stated over the single book it lands in. Nothing here derives either from the deployment: an act that could not say whose book it meant is an act that would have to guess, and guessing is how one person is handed another person's correspondents.

Each write is idempotent from a fresh read and is committed through the optimistic concurrency policy, so two callers claiming one address converge on the same answer instead of one of them meeting a provider failure: the loser's insert violates the unique constraint over the book and the address, the retry re-reads, and the second caller is told which contact of that book holds it.

Nothing here logs. A name, an address, and a note are personal data about a third party, and the outcomes this type produces are what a surface reports; a log line about a write would put the whole book into a log within a week of somebody using it.

Every act states the grant it is reached under, because a check that lived only in a route would be one a second entrypoint forgets. Reading the book is AdminAuditRead, since a collected contact is somebody this deployment learned about from correspondence rather than a report of its own state; writing one is AdminOperate; and erasing a person is AdminErase, beside the erasure of stored mail.

Two surfaces perform this book's writes and each publishes them under a name of its own, so recording, amending, and erasing admit the administrative grant above or ContactsWrite, which is what an agent reaching the contact tools holds. The halves are disjoint, so requiring one name would leave the act reachable from the operator and dead from the protocol. Promotion is written the same way and for the same reason: a collected record exists to be taken on, and an agent that read the book has the same standing to do it as an operator at a terminal. The alternative stops where the act does — exporting a person answers a data-subject request rather than an agent's question, and erasing a mailbox's whole collected book is a user reversing a decision they made in configuration.

Collection from arriving mail is work no caller requests, so the two acts it performs — asking whether an address is spoken for in the account's own book, and recording somebody in it — admit MailFathom's own process identity instead of a grant. A permission there would make writing into a collected book reachable by whoever an operator granted that name to, which is the authority the origin rule exists to keep away from a caller.

Constructors

ContactBook(IContactStore, IContactDirectory, OptimisticConcurrencyRetryPolicy, TimeProvider, AccessAuthorization)

Initializes the book over the store it writes to and the directory it reads from.

Methods

AmendAsync(ContactBookScope, ContactAmendment, CancellationToken)

Amends a contact of the caller's own book to the record they state, if its origin admits that writer.

CollectAsync(MailAccountId, NewContact, CancellationToken)

Records a person collection inferred from arriving mail, in the book of the account it arrived on.

EraseAsync(ContactBookScope, ContactId, CancellationToken)

Erases one person and everything the book derived from them.

EraseCollectedAsync(MailAccountId, CancellationToken)

Erases the whole of one mail account's collected book, leaving every user's own book where it is.

ExportAsync(ContactBookScope, ContactId, CancellationToken)

Produces everything the books hold about one person.

FindAsync(ContactBookScope, ContactId, CancellationToken)

Reads one contact by the identity the book gave it.

FindByAddressAsync(ContactBookScope, EmailAddress, CancellationToken)

Reads the person who uses one address.

HoldsAddressAsync(MailAccountId, EmailAddress, CancellationToken)

Answers whether one account's own book already holds an address, without answering whose it is.

PromoteAsync(ContactBookScope, ContactId, ContactOrigin, CancellationToken)

Takes a collected contact on, by writing the user's own copy of it.

ReadPageAsync(ContactBookScope, ContactQuery, CancellationToken)

Reads one bounded page of the books a scope reads.

RecordAsync(UserId, NewContact, CancellationToken)

Records a person one user's own book does not yet hold.