/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:
@@ -21,12 +21,6 @@ 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(
|
||||
@@ -46,7 +40,6 @@ public class FetchEmailsQueryHandler(
|
||||
return await ImapService.FetchEmailsAsync(
|
||||
account,
|
||||
request.Mail,
|
||||
request.MarkAsSeen,
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user