/s
Simplify IMAP email fetching API and refactor logic Removed `markAsSeen` parameter from `FetchEmailsAsync` and `FetchEmailByUidAsync` methods in `IImapEmailService` to simplify the API. Updated `MailSearchFilter` to make `MaxCount` nullable for greater flexibility. Removed `markAsSeen` from `FetchEmailByUidQuery` and `FetchEmailsQuery` records and their handlers. Deleted `FetchEmailByUidQueryValidator` as it is no longer needed. Refactored `LimilabsImapEmailService`: - Introduced `FetchEmailUidsAsync` to centralize UID fetching logic. - Simplified `FetchEmailByUidAsync` using a new helper method. - Consolidated connection, authentication, and folder selection into reusable private methods. - Removed redundant code for search criteria and flag fetching. Removed `IsSeen` from `ReceivedEmailContext` and improved overall code readability and maintainability by reducing duplication and centralizing logic.
This commit is contained in:
@@ -13,7 +13,6 @@ 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>
|
||||
@@ -21,7 +20,6 @@ public interface IImapEmailService
|
||||
Task<IEnumerable<ReceivedEmailContext>> FetchEmailsAsync(
|
||||
EmailAccountDto account,
|
||||
MailSearchFilter filter,
|
||||
bool markAsSeen = true,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
@@ -35,7 +33,6 @@ 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>
|
||||
@@ -44,7 +41,6 @@ public interface IImapEmailService
|
||||
long uid,
|
||||
string folder = "INBOX",
|
||||
bool withAttachments = false,
|
||||
bool markAsSeen = true,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user