Class MailRuleActionRecorder
- Namespace
- MailFathom.Application.Rules.Actions
- Assembly
- MailFathom.Application.dll
Writes down the changes one email's matching rules ask for, as the mutation records every requester uses.
public sealed class MailRuleActionRecorder
- Inheritance
-
MailRuleActionRecorder
- Inherited Members
Remarks
This is the join between a rule and a mailbox, and it is deliberately the whole of it. Nothing here issues an IMAP command: it opens a durable record per action, and the account's own convergence pass carries each record to a completed or a dead-lettered ending exactly as it carries a change somebody authored by hand. What this adds is the identity, the order, and the refusal of an action whose account or destination has stopped permitting it.
A held account is the exception, because it has no server to converge with. There the action is committed to the stored email in the caller's session and no record is opened, so an action reaches the recorded list with no record identifier, and what it applied is handed back for Announce(IEnumerable<AppliedMailboxChange>) to publish once the batch has committed.
What an account permits is read here as well as when the rule set is read, and the second reading is not redundant: the two configuration sections reload independently, so narrowing what an account permits leaves a rule set nobody edited in force. Without this, a revoked permission would take effect at the next edit of the rules rather than at the next pass, which for a deletion is the wrong way round.
The records, and a held account's committed changes, join the caller's session, so a batch's evaluations and the requests they produced commit together. A crash between them is therefore impossible in the direction that matters: an email is never recorded as evaluated while the change its rules asked for was lost, and a rolled-back batch is evaluated again and asks again under the same identity.
Where a destination is is not resolved here. The answers are handed in, already resolved, because resolving one can reach the mail server and nothing may do that while the batch's transaction is open. A rule is one author of a filing mutation among others, and the folder it files into is found the same way for all of them.
Constructors
- MailRuleActionRecorder(MailboxChangeSubmission, IAuthoredDeleteEmailDispositionReader, IMailRuleActionPermissionReader)
Initializes the recorder from the submission it writes through and the decisions it has to read.
Methods
- Announce(IEnumerable<AppliedMailboxChange>)
Tells the clients watching each account about the changes a held account committed.
- PrepareCopiesAsync(MailAccountId, IReadOnlyCollection<StoredEmailId>, CancellationToken)
Places the payload of every copy a batch asks for, before the transaction that records them opens.
- RecordAsync(IPersistenceSession, StoredEmailId, EmailOccurrenceId?, MailRuleActionPlan, MailRuleSetRevision, MailboxDestinations, PreparedLocalCopies, CancellationToken)
Opens one mutation record per action the plan honors, in the order the changes are applied.