feat(imap): add markAsSeen option to fetch queries and interface

- IImapEmailService.FetchEmailsAsync / FetchEmailByUidAsync now accept
  a bool markAsSeen = true parameter
- FetchEmailsQuery and FetchEmailByUidQuery expose MarkAsSeen { init; } = true
- markAsSeen=true  uses BODY[]      (server sets \\Seen, legacy-compatible)
- markAsSeen=false uses BODY.PEEK[] (non-destructive read, flag untouched)
This commit is contained in:
2026-08-11 15:51:57 +02:00
parent 962cb52e0b
commit e840d026aa
3 changed files with 23 additions and 0 deletions

View File

@@ -13,10 +13,15 @@ public interface IImapEmailService
/// </summary>
/// <param name="account">Account whose IMAP settings will be used.</param>
/// <param name="filter">Filter to apply when fetching emails.</param>
/// <param name="markAsSeen">
/// When <see langword="true"/> (default), fetched messages are marked as <c>\Seen</c> on the server.
/// Set to <see langword="false"/> for a non-destructive read (uses <c>BODY.PEEK</c> internally).
/// </param>
/// <param name="cancellationToken">Cancellation token.</param>
Task<IEnumerable<ReceivedEmailContext>> FetchEmailsAsync(
EmailAccountDto account,
MailSearchFilter filter,
bool markAsSeen = true,
CancellationToken cancellationToken = default);
/// <summary>
@@ -30,11 +35,16 @@ public interface IImapEmailService
/// <summary>
/// Fetches a single email by its UID.
/// </summary>
/// <param name="markAsSeen">
/// When <see langword="true"/> (default), the message is marked as <c>\Seen</c> on the server.
/// Set to <see langword="false"/> for a non-destructive read.
/// </param>
Task<ReceivedEmailContext?> FetchEmailByUidAsync(
EmailAccountDto account,
long uid,
string folder = "INBOX",
bool withAttachments = false,
bool markAsSeen = true,
CancellationToken cancellationToken = default);
/// <summary>