Refactored impa synchronization.

This commit is contained in:
Burak Kaan Köse
2026-02-14 12:52:17 +01:00
parent 4a0dcd2899
commit 744145be06
26 changed files with 1492 additions and 1243 deletions
@@ -29,6 +29,8 @@ public class MailItemFolder : IMailItemFolder
// For IMAP
public uint UidValidity { get; set; }
public long HighestModeSeq { get; set; }
public uint HighestKnownUid { get; set; }
public DateTime? LastUidReconcileUtc { get; set; }
/// <summary>
/// Outlook shares delta changes per-folder. Gmail is for per-account.
@@ -79,6 +79,13 @@ public interface IFolderService
/// <param name="folder">Folder to update.</param>
Task UpdateFolderAsync(MailItemFolder folder);
/// <summary>
/// Updates only IMAP HighestModeSeq for the given folder.
/// </summary>
/// <param name="folderId">Folder id to update.</param>
/// <param name="highestModeSeq">Latest known mod-seq value.</param>
Task UpdateFolderHighestModeSeqAsync(Guid folderId, long highestModeSeq);
/// <summary>
/// Returns the active folder menu items for the given account for UI.
/// </summary>
@@ -1,11 +0,0 @@
using MailKit.Net.Imap;
namespace Wino.Core.Domain.Interfaces;
/// <summary>
/// Provides a synchronization strategy for synchronizing IMAP folders based on the server capabilities.
/// </summary>
public interface IImapSynchronizationStrategyProvider
{
IImapSynchronizerStrategy GetSynchronizationStrategy(IImapClient client);
}
@@ -1,40 +0,0 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MailKit;
using MailKit.Net.Imap;
using Wino.Core.Domain.Entities.Mail;
namespace Wino.Core.Domain.Interfaces;
public interface IImapSynchronizerStrategy
{
/// <summary>
/// Synchronizes given folder with the ImapClient client from the client pool.
/// </summary>
/// <param name="client">Client to perform sync with. I love Mira and Jasminka</param>
/// <param name="folder">Folder to synchronize.</param>
/// <param name="synchronizer">Imap synchronizer that downloads messages.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>List of new downloaded message ids that don't exist locally.</returns>
Task<List<string>> HandleSynchronizationAsync(IImapClient client,
MailItemFolder folder,
IImapSynchronizer synchronizer,
CancellationToken cancellationToken = default);
/// <summary>
/// Downloads given set of messages from the folder.
/// Folder is expected to be opened and synchronizer is connected.
/// </summary>
/// <param name="synchronizer">Synchronizer that performs the action.</param>
/// <param name="remoteFolder">Remote folder to download messages from.</param>
/// <param name="localFolder">Local folder to assign mails to.</param>
/// <param name="uniqueIdSet">Set of message uniqueids.</param>
/// <param name="cancellationToken">Cancellation token.</param>
Task DownloadMessagesAsync(IImapSynchronizer synchronizer,
IMailFolder remoteFolder,
MailItemFolder localFolder,
UniqueIdSet uniqueIdSet,
CancellationToken cancellationToken = default);
}
@@ -10,12 +10,14 @@ public interface IMailItemFolder
string DeltaToken { get; set; }
string FolderName { get; set; }
long HighestModeSeq { get; set; }
uint HighestKnownUid { get; set; }
Guid Id { get; set; }
bool IsHidden { get; set; }
bool IsSticky { get; set; }
bool IsSynchronizationEnabled { get; set; }
bool IsSystemFolder { get; set; }
DateTime? LastSynchronizedDate { get; set; }
DateTime? LastUidReconcileUtc { get; set; }
Guid MailAccountId { get; set; }
string ParentRemoteFolderId { get; set; }
string RemoteFolderId { get; set; }