Remove HasAttachments filter; enhance FetchEmails response
The `MailSearchFilter` class was updated to remove the `HasAttachments` property, simplifying the filtering logic. Corresponding client-side filtering logic in `LimilabsImapEmailService` was also removed. The IMAP search query now defaults to `Expression.All` when no criteria are provided. The `FetchEmails` method in `EmailController` was enhanced with a new optional `firstHtmlBodyOnly` parameter. This allows returning only the HTML body of the first email or a `404 Not Found` response if no emails match the criteria. These changes improve flexibility and simplify the codebase.
This commit is contained in:
@@ -78,7 +78,8 @@ public class LimilabsImapEmailService(
|
||||
}
|
||||
|
||||
// Get UIDs to fetch
|
||||
List<long> uids = [.. await imap.SearchAsync(Expression.And([.. criterions]), cancellationToken)];
|
||||
var searchExpression = criterions.Count > 0 ? Expression.And([.. criterions]) : Expression.All();
|
||||
List<long> uids = [.. await imap.SearchAsync(searchExpression, cancellationToken)];
|
||||
|
||||
// Apply requested sort order
|
||||
if (filter.SortOrder == MailSortOrder.NewestFirst)
|
||||
@@ -99,10 +100,6 @@ public class LimilabsImapEmailService(
|
||||
var mail = new MailBuilder().CreateFromEml(eml);
|
||||
var flags = await imap.GetFlagsByUIDAsync(uid, cancellationToken);
|
||||
|
||||
// Client-side attachment filter — IMAP has no native criterion for this
|
||||
if (filter.HasAttachments && mail.Attachments.Count == 0 && mail.Visuals.Count == 0)
|
||||
continue;
|
||||
|
||||
results.Add(MapToContext(uid, mail, flags, filter.WithAttachments));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user