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:
@@ -27,7 +27,6 @@ public class LimilabsImapEmailService(
|
||||
public async Task<IEnumerable<ReceivedEmailContext>> FetchEmailsAsync(
|
||||
EmailAccountDto account,
|
||||
MailSearchFilter filter,
|
||||
bool withAttachments = false,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var imap = new Imap();
|
||||
@@ -104,7 +103,7 @@ public class LimilabsImapEmailService(
|
||||
if (filter.HasAttachments && mail.Attachments.Count == 0 && mail.Visuals.Count == 0)
|
||||
continue;
|
||||
|
||||
results.Add(MapToContext(uid, mail, flags, withAttachments));
|
||||
results.Add(MapToContext(uid, mail, flags, filter.WithAttachments));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user