Refactor attachment handling in email fetching
Consolidate `WithAttachments` behavior into `MailSearchFilter` to simplify the API and reduce redundancy. - Removed `withAttachments` parameter from `FetchEmailsAsync` in `IImapEmailService`. - Added `WithAttachments` property to `MailSearchFilter` to control attachment inclusion. - Removed `WithAttachments` property from `FetchEmailsQuery` as it is now encapsulated in `MailSearchFilter`. - Updated `FetchEmailsQueryHandler` to use `MailSearchFilter` for attachment handling. - Refactored `LimilabsImapEmailService` to use `MailSearchFilter.WithAttachments` for mapping email data. These changes improve maintainability and clarity by centralizing attachment-related options in `MailSearchFilter`.
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"/>, attachment data is included in the results; otherwise attachments are omitted.
|
||||
/// Defaults to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public bool WithAttachments { get; init; } = false;
|
||||
}
|
||||
|
||||
public class FetchEmailsQueryHandler(
|
||||
@@ -46,7 +40,6 @@ public class FetchEmailsQueryHandler(
|
||||
return await ImapService.FetchEmailsAsync(
|
||||
account,
|
||||
request.Mail,
|
||||
request.WithAttachments,
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user