Table of Contents

Interface ITeamMailStore

Namespace
Tharga.Team
Assembly
Tharga.Team.dll

Keeps received mail, for a team's mailbox and for the postmaster. The persistence port behind ITeamMailboxService and IPostmasterService.

public interface ITeamMailStore

Remarks

A mail with no team is the postmaster's. Every team-scoped read names its team, and a mail held by the postmaster is reachable only through the postmaster operations, so a team id never reaches unrouted mail.

Adding is the deduplication. A mail's id is derived from what it is — the same delivery read twice gets the same id — and AddAsync(InboundMailItem, CancellationToken) refuses an id it already holds, durably. Two instances reading the same mailbox, or one re-reading after a crash, therefore store each delivery once.

Methods

AddAsync(InboundMailItem, CancellationToken)

Keeps a received mail; false, and nothing written, when a mail with this id is already kept.

Task<bool> AddAsync(InboundMailItem item, CancellationToken cancellationToken = default)

Parameters

item InboundMailItem
cancellationToken CancellationToken

Returns

Task<bool>

ArchiveUnroutedAsync(string, string, DateTime, CancellationToken)

Marks a held mail Archived, with who and when, in one conditional write; null, and nothing changed, when the postmaster holds no mail by this id or it is already archived.

Task<InboundMailItem> ArchiveUnroutedAsync(string mailId, string archivedBy, DateTime archivedAt, CancellationToken cancellationToken = default)

Parameters

mailId string
archivedBy string
archivedAt DateTime
cancellationToken CancellationToken

Returns

Task<InboundMailItem>

CountUnhandledAsync(string, CancellationToken)

How many of a team's mails nobody has handled.

Task<int> CountUnhandledAsync(string teamKey, CancellationToken cancellationToken = default)

Parameters

teamKey string
cancellationToken CancellationToken

Returns

Task<int>

CountUnroutedAsync(CancellationToken)

How much mail the postmaster holds that nobody archived.

Task<int> CountUnroutedAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<int>

DeleteForTeamAsync(string, CancellationToken)

Removes every mail a team holds, when the team itself is removed, and says which.

Task<string[]> DeleteForTeamAsync(string teamKey, CancellationToken cancellationToken = default)

Parameters

teamKey string
cancellationToken CancellationToken

Returns

Task<string[]>

DeleteUnroutedReceivedBeforeAsync(DateTime, CancellationToken)

Removes the postmaster's mail received before a moment, archived or not, and says which, so their content can go too.

Task<string[]> DeleteUnroutedReceivedBeforeAsync(DateTime receivedBefore, CancellationToken cancellationToken = default)

Parameters

receivedBefore DateTime
cancellationToken CancellationToken

Returns

Task<string[]>

GetAsync(string, string, CancellationToken)

One of a team's mails, or null when the team has none by this id.

Task<InboundMailItem> GetAsync(string teamKey, string mailId, CancellationToken cancellationToken = default)

Parameters

teamKey string
mailId string
cancellationToken CancellationToken

Returns

Task<InboundMailItem>

GetUnroutedAsync(string, CancellationToken)

One mail the postmaster holds, archived or not, or null when it holds none by this id.

Task<InboundMailItem> GetUnroutedAsync(string mailId, CancellationToken cancellationToken = default)

Parameters

mailId string
cancellationToken CancellationToken

Returns

Task<InboundMailItem>

ListAsync(string, InboundMailFilter, string, int, CancellationToken)

A page of a team's mail, newest first.

Task<InboundMailPage> ListAsync(string teamKey, InboundMailFilter filter, string cursor, int pageSize, CancellationToken cancellationToken = default)

Parameters

teamKey string
filter InboundMailFilter
cursor string
pageSize int
cancellationToken CancellationToken

Returns

Task<InboundMailPage>

ListUnroutedAsync(string, int, CancellationToken)

A page of the mail the postmaster holds and nobody archived, newest first.

Task<InboundMailPage> ListUnroutedAsync(string cursor, int pageSize, CancellationToken cancellationToken = default)

Parameters

cursor string
pageSize int
cancellationToken CancellationToken

Returns

Task<InboundMailPage>

ListUnroutedAsync(PostmasterMailState, string, int, CancellationToken)

A page of the postmaster's mail in one state, newest received first: held is mail with no outcome, archived is mail whose outcome is Archived.

Task<InboundMailPage> ListUnroutedAsync(PostmasterMailState state, string cursor, int pageSize, CancellationToken cancellationToken = default)

Parameters

state PostmasterMailState
cursor string
pageSize int
cancellationToken CancellationToken

Returns

Task<InboundMailPage>

Remarks

A default member so a host's own store keeps compiling; it lists held mail through the call above and refuses archived mail until implemented.

RestoreUnroutedAsync(string, CancellationToken)

Clears the outcome, and who and when, of an archived mail in one conditional write; null, and nothing changed, when the postmaster holds no archived mail by this id.

Task<InboundMailItem> RestoreUnroutedAsync(string mailId, CancellationToken cancellationToken = default)

Parameters

mailId string
cancellationToken CancellationToken

Returns

Task<InboundMailItem>

RouteAsync(string, string, CancellationToken)

Moves a mail from the postmaster to a team, marked as rerouted and with any outcome cleared, so it arrives unhandled; null, and nothing changed, when the postmaster no longer holds it — someone else routed it first.

Task<InboundMailItem> RouteAsync(string mailId, string teamKey, CancellationToken cancellationToken = default)

Parameters

mailId string
teamKey string
cancellationToken CancellationToken

Returns

Task<InboundMailItem>

SetOutcomeAsync(string, string, string, MailThreadOwner, string, DateTime, CancellationToken)

Records what became of one of a team's mails; null when the team has none by this id.

Task<InboundMailItem> SetOutcomeAsync(string teamKey, string mailId, string outcome, MailThreadOwner owner, string handledBy, DateTime handledAt, CancellationToken cancellationToken = default)

Parameters

teamKey string
mailId string
outcome string
owner MailThreadOwner
handledBy string
handledAt DateTime
cancellationToken CancellationToken

Returns

Task<InboundMailItem>