Class RedactingEmailMimeReader
- Namespace
- MailFathom.Application.Emails.Extraction
- Assembly
- MailFathom.Application.dll
Replaces what an account's switched-on scanner finds in a message's body before anything is derived from it.
public sealed class RedactingEmailMimeReader : IEmailMimeReader
- Inheritance
-
RedactingEmailMimeReader
- Implements
- Inherited Members
Remarks
One decorator rather than a redaction inside each writer, because this port is where every derived copy of a body begins: the search document, the passages cut from it, and the vectors built from those passages all descend from one ExtractedEmailText, and both paths that produce one — synchronization reading a message it has just fetched, and the backfill re-reading raw MIME stored before extraction existed — reach it through here. Redacting at this seam is therefore what makes the placeholder the thing that is stored, chunked, embedded, and later retrieved, with nothing downstream needing to know a scanner exists.
What is looked for is the account's, and the account arrives with the message. A deployment serves several mailboxes and one of them may have switched a scanner on that the deployment left off, so the body is redacted under the posture of the mailbox the mail is in rather than under one answer for the whole store. Both paths that reach here already hold it, which is why the port carries it rather than resolving it.
The body is what is redacted, and only the body. A subject, an address, and a thread identifier are the envelope's routing metadata rather than derived text: they are what a listing filters on and what a reply is addressed to, so replacing them would remove a stored message's whole use, and what protects them on their way out is the egress guard rather than the derived store. The stored raw MIME is untouched by all of this, as it is everywhere in this feature.
It fails closed. A detector that cannot answer refuses the read rather than yielding text nothing scanned, and the refusal reaches whichever run asked: a synchronization run stops on that message with its checkpoint where it was, and a backfill batch is discarded and resumes from its last committed position. Both retry. Both readings are redacted: the trimmed reading is what the lexical index covers and the untrimmed one is what survives an over-aggressive trim, so a credential removed from one and left in the other would be a credential in the derived store. They cost one scan where they are the same string, which is the ordinary message, and two where trimming removed something.
Constructors
- RedactingEmailMimeReader(IEmailMimeReader, SensitiveContentDerivationGuard)
Initializes a reader that redacts what the one it wraps extracted.
Methods
- ReadMetadataAsync(MailAccountId, ReadOnlyMemory<byte>, CancellationToken)
Reads one message's normalized metadata.