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:
@@ -14,4 +14,10 @@ public class EmailAccountsOptions
|
||||
/// The list of configured email accounts.
|
||||
/// </summary>
|
||||
public required IEnumerable<EmailAccountDto> Accounts { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// How often the IMAP sync worker polls for new emails, in seconds.
|
||||
/// Defaults to 300 seconds (5 minutes).
|
||||
/// </summary>
|
||||
public int SyncIntervalSeconds { get; init; } = 300;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user