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 the whole collected half, and export one.
public sealed class ContactBook
- Inheritance
-
ContactBook
- Inherited Members
Remarks
Every surface over the book — 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 an owner wrote down, and an owner 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 owner's rather than something collection can perform on its own behalf.
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 addresses, the retry re-reads, and the second caller is told which contact 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 MailContactsWrite, 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 the whole collected half is an owner 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, and recording somebody under the collected origin — admit MailFathom's own process identity instead of a grant. A permission there would make writing into the collected origin 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(ContactAmendment, CancellationToken)
Amends a contact to the record the caller states, if its origin admits that writer.
- CollectAsync(NewContact, CancellationToken)
Records a person collection inferred from arriving mail.
- EraseAsync(ContactId, CancellationToken)
Erases one person and everything the book derived from them.
- EraseCollectedAsync(CancellationToken)
Erases every contact this deployment collected, leaving the ones the owner asserted where they are.
- ExportAsync(ContactId, CancellationToken)
Produces everything the book holds about one person.
- FindAsync(ContactId, CancellationToken)
Reads one contact by the identity the book gave it.
- FindByAddressAsync(EmailAddress, CancellationToken)
Reads the person who uses one address.
- HoldsAddressAsync(EmailAddress, CancellationToken)
Answers whether the book already holds one address, without answering whose it is.
- PromoteAsync(ContactId, ContactOrigin, CancellationToken)
Promotes a collected contact to one the owner has taken responsibility for.
- ReadPageAsync(ContactQuery, CancellationToken)
Reads one bounded page of the book.
- RecordAsync(NewContact, CancellationToken)
Records a person the book does not yet hold.