Table of Contents

Method AppendAsync

Namespace
MailFathom.Application.Agent.Conversations
Assembly
MailFathom.Application.dll

AppendAsync(AgentConversationId, UserId, AgentConversationEntry, DateTimeOffset, CancellationToken)

Writes one entry into a conversation, giving it the next place in that conversation.

Task<long?> AppendAsync(AgentConversationId id, UserId user, AgentConversationEntry entry, DateTimeOffset now, CancellationToken cancellationToken)

Parameters

id AgentConversationId

The conversation the entry belongs to.

user UserId

The person whose conversation it has to be.

entry AgentConversationEntry

What happened, carrying neither a conversation nor a place of its own.

now DateTimeOffset

The instant the entry was written, in UTC.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<long?>

The place the entry was written at, or null when nothing was written.

Remarks

The place starts at 1 and never skips, because the conversation's own counter is advanced inside the statement that writes the row rather than by anything counting outside the database. That also serializes two writers against each other, which a conversation genuinely has: a person may type while a run is composing.

Nothing is written for a conversation that does not exist, for one that is not this person's, for one that is full on either of its two ceilings, for an entry belonging to an answer that is not the one being composed, or for an answer opened while another is still being composed. Each of those is a statement about the conversation rather than a fault, so the caller stops rather than retrying.

An entry of the visible history counts against MaximumEntries and against MaximumRecordedEntries; an entry of the technical history alone counts against the second only, which is what keeps a run's tool traffic from shortening what a person can keep working in.

The person is checked here as everywhere else, and it is worth saying why the run's own writes are not the exception they look like. This is the path a person's own typed question takes as much as the path a composing run takes, so leaving the check to the caller would leave one write in this store — the only one somebody outside the deployment can cause — resting on a route remembering to do what every sibling method does itself. The run always knows whose conversation it is answering in, so nothing is bought by exempting it.

Exceptions

ArgumentNullException

Thrown when entry is null.

ArgumentException

Thrown when the entry answers a proposal, which is recorded through TryResolveProposalAsync(AgentConversationId, UserId, long, AgentProposalState, DateTimeOffset, CancellationToken) because it is a person's act rather than a run's.