Method FindRefusalAsync
- Namespace
- MailFathom.Application.Mail.Delivery.Screening
- Assembly
- MailFathom.Application.dll
FindRefusalAsync(MailAccountId, ReadOnlyMemory<byte>, CancellationToken)
Screens one composed message and reports what stops it, if anything does.
public Task<SensitiveContentEgressRefusal?> FindRefusalAsync(MailAccountId account, ReadOnlyMemory<byte> rawMime, CancellationToken cancellationToken)
Parameters
accountMailAccountIdThe account the message is being sent or filed from, whose posture its findings are judged by.
rawMimeReadOnlyMemory<byte>The RFC 822 bytes about to be stored and transmitted or filed.
cancellationTokenCancellationTokenCancels the parse and the scan.
Returns
- Task<SensitiveContentEgressRefusal>
What stopped the act, or null where nothing did.
Remarks
The answer is returned rather than raised, because the two callers refuse in different words: one did not queue a message and the other did not write a draft, and a shared exception would tell one author about the other's act. What is not returned is anything about the finding beyond the category — see SensitiveContentEgressRefusal for what that costs and why.
The emptiness guard is above the active test rather than left to the reader, so what may be handed to this method does not depend on what an operator or an account switched on. The outbox refuses empty bytes of its own accord and the draft book does not, and an account screening nothing would otherwise file a draft of no message at all while the account beside it was refused one.
Exceptions
- ArgumentException
Thrown when
rawMimeis empty.- SensitiveContentScannerUnavailableException
Thrown when a switched-on scanner could not establish what the message carries, which stops the act.
- OperationCanceledException
Thrown when
cancellationTokenis cancelled.