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

@@ -21,6 +21,12 @@ public record FetchEmailsQuery : IRequest<IEnumerable<ReceivedEmailContext>>
/// Mail query used to filter and limit the emails retrieved.
/// </summary>
public MailSearchFilter Mail { get; init; } = new();
/// <summary>
/// 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 peek.
/// </summary>
public bool MarkAsSeen { get; init; } = true;
}
public class FetchEmailsQueryHandler(
@@ -40,6 +46,7 @@ public class FetchEmailsQueryHandler(
return await ImapService.FetchEmailsAsync(
account,
request.Mail,
request.MarkAsSeen,
cancellationToken);
}
}