Method PromoteAsync
- Namespace
- MailFathom.Application.Contacts
- Assembly
- MailFathom.Application.dll
PromoteAsync(ContactId, ContactOrigin, CancellationToken)
Promotes a collected contact to one the owner has taken responsibility for.
public Task<ContactWriteResult> PromoteAsync(ContactId contactId, ContactOrigin writer, CancellationToken cancellationToken)
Parameters
contactIdContactIdThe contact to promote.
writerContactOriginThe origin the writer acts under.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task<ContactWriteResult>
The promoted record, or the refusal naming what stopped it.
Remarks
The one act that changes an origin, and it runs one way. It is gated on the writer for the reason an amendment is: promotion is the owner taking a record on, so collection asking for it is refused rather than granted the authority it was about to award itself. A contact that is already asserted is answered as such rather than written again, so an owner repeating the request learns that nothing was left to do.
The writer and the grant answer different questions and both are asked: the grant says whether this caller may write to the book at all, and the writer says whether the record's own origin admits what it is about to do.
Both surfaces reach it, because promotion is what a collected record is *for*: an agent that read the book and found somebody the deployment picked up has the same standing to take that record on as an operator at a terminal, and a promotion reachable from one of them would leave collection's own output editable from the other only by erasing it and writing it again. What the alternative does not widen is which writer may perform it — collection acts under its own origin and IsPromotableBy(ContactOrigin) refuses it there.
Exceptions
- PersistenceConcurrencyConflictException
Thrown when every allowed attempt lost the race.
- PrincipalNotAuthorizedException
Thrown when the write was reached by anything but a caller granted AdminOperate or MailContactsWrite.