Add EmailSyncWorker and enhance IMAP service with caching

Refactored `ReceivedEmailContext` to use `record` for immutability
and value-based equality. Added `SyncIntervalSeconds` to
`EmailAccountsOptions` for configuring IMAP sync intervals.

Introduced `EmailSyncWorker` as a background service for periodic
email synchronization. Registered `IMemoryCache` and integrated
caching in `LimilabsImapEmailService` to reduce redundant fetch
operations. Optimized `FetchEmailByUidAsync` to conditionally
handle attachments and improve performance.

Refactored logging and improved code readability by adopting modern
C# features like `record`, `with` expressions, and `IOptions`.
Performed general cleanup and streamlined method implementations.
This commit is contained in:
2026-08-12 11:48:29 +02:00
parent f521683608
commit a446162afa
5 changed files with 112 additions and 48 deletions

View File

@@ -50,6 +50,9 @@ public static class DependencyInjection
// Register Background Workers
services.AddHostedService<AsyncInitWorker>();
services.AddHostedService<EmailSyncWorker>();
services.AddMemoryCache();
return services;
}