Refactor IMAP email fetching to use SearchFilter
Replaced individual parameters (`folder`, `unseenOnly`, `maxCount`) in `IImapEmailService` with a consolidated `SearchFilter` object to simplify method signatures and improve maintainability. Renamed `MailQuery` to `SearchFilter` in `FetchEmailsQuery` for better clarity. Updated `FetchEmailsQueryHandler` and `LimilabsImapEmailService` to use the new `SearchFilter` object, ensuring consistent handling of folder selection, unread message filtering, and message count limits. Improved logging in `LimilabsImapEmailService` to reflect the updated `SearchFilter` structure.
This commit is contained in:
@@ -19,9 +19,9 @@ public record FetchEmailsQuery : IRequest<IEnumerable<ReceivedEmailContext>>
|
||||
/// <summary>
|
||||
/// Mail query used to filter and limit the emails retrieved.
|
||||
/// </summary>
|
||||
public MailQuery Mail { get; init; } = new();
|
||||
public SearchFilter Mail { get; init; } = new();
|
||||
|
||||
public record MailQuery
|
||||
public record SearchFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Mailbox folder to read from (default: "INBOX").
|
||||
@@ -56,9 +56,7 @@ public class FetchEmailsQueryHandler(
|
||||
|
||||
return await ImapService.FetchEmailsAsync(
|
||||
account,
|
||||
request.Mail.Folder,
|
||||
request.Mail.UnseenOnly,
|
||||
request.Mail.MaxCount,
|
||||
request.Mail,
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user