Refactor IMAP service for repository integration

Replaced `FetchEmailsAsync` with `SyncEmailsAsync` in `IImapEmailService` to simplify email synchronization. Updated method signatures to use `DateFilter` and added default parameters for `folder` and `cancel`.

Refactored `LimilabsImapEmailService` to remove client-side filtering logic and delegate storage to `IRepository<ReceivedEmail>`. Simplified IMAP search criteria to focus on date-based filtering and added checks to skip already-synced emails.

Updated `EmailSyncWorker` to use the new `SyncEmailsAsync` method. Removed unused code, streamlined exception handling, and improved maintainability by reducing complexity and focusing on server-side filtering.
This commit is contained in:
2026-08-13 14:18:43 +02:00
parent 7207c5b4d9
commit 4964fa4344
3 changed files with 31 additions and 84 deletions

View File

@@ -14,15 +14,16 @@ public interface IImapEmailService
/// Fetches emails from the specified mailbox folder.
/// </summary>
/// <param name="account">Account whose IMAP settings will be used.</param>
/// <param name="filter">Filter to apply when fetching emails.</param>
/// <param name="date"></param>
/// 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 read (uses <c>BODY.PEEK</c> internally).
/// </param>
/// <param name="cancellationToken">Cancellation token.</param>
Task<IEnumerable<ReceivedEmailDto>> FetchEmailsAsync(
public Task SyncEmailsAsync(
EmailAccount account,
MailSearchFilter filter,
CancellationToken cancellationToken = default);
DateFilter date,
string folder = "INBOX",
CancellationToken cancel = default);
/// <summary>
/// Marks a message as seen (read) on the server.