IDLE implementation, imap synchronization strategies basics and condstore synchronization.
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
{
|
||||
public enum MailSynchronizationType
|
||||
{
|
||||
// Shared
|
||||
UpdateProfile, // Only update profile information
|
||||
ExecuteRequests, // Run the queued requests, and then synchronize if needed.
|
||||
FoldersOnly, // Only synchronize folder metadata.
|
||||
InboxOnly, // Only Inbox, Sent and Draft folders.
|
||||
InboxOnly, // Only Inbox, Sent, Draft and Deleted folders.
|
||||
CustomFolders, // Only sync folders that are specified in the options.
|
||||
FullFolders, // Synchronize all folders. This won't update profile or alias information.
|
||||
Alias, // Only update alias information
|
||||
IMAPIdle // Idle client triggered synchronization.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Wino.Core.Domain.Exceptions
|
||||
{
|
||||
public class ImapSynchronizerStrategyException : System.Exception
|
||||
{
|
||||
public ImapSynchronizerStrategyException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,10 @@ namespace Wino.Core.Domain.Interfaces
|
||||
/// Which folders to sync after this operation?
|
||||
/// </summary>
|
||||
List<Guid> SynchronizationFolderIds { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, additional folders like Sent, Drafts and Deleted will not be synchronized
|
||||
/// </summary>
|
||||
bool ExcludeMustHaveFolders { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
15
Wino.Core.Domain/Interfaces/IImapSynchronizer.cs
Normal file
15
Wino.Core.Domain/Interfaces/IImapSynchronizer.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Models.MailItem;
|
||||
|
||||
namespace Wino.Core.Domain.Interfaces
|
||||
{
|
||||
public interface IImapSynchronizer
|
||||
{
|
||||
Task<List<NewMailItemPackage>> CreateNewMailPackagesAsync(ImapMessageCreationPackage message, MailItemFolder assignedFolder, CancellationToken cancellationToken = default);
|
||||
Task StartIdleClientAsync();
|
||||
Task StopIdleClientAsync();
|
||||
}
|
||||
}
|
||||
22
Wino.Core.Domain/Interfaces/IImapSynchronizerStrategy.cs
Normal file
22
Wino.Core.Domain/Interfaces/IImapSynchronizerStrategy.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MailKit;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Models.MailItem;
|
||||
@@ -108,5 +109,13 @@ namespace Wino.Core.Domain.Interfaces
|
||||
/// <param name="draftCreationOptions">Options like new email/forward/draft.</param>
|
||||
/// <returns>Draft MailCopy and Draft MimeMessage as base64.</returns>
|
||||
Task<(MailCopy draftMailCopy, string draftBase64MimeMessage)> CreateDraftAsync(Guid accountId, DraftCreationOptions draftCreationOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Returns ids
|
||||
/// </summary>
|
||||
/// <param name="folderId"></param>
|
||||
/// <param name="uniqueIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<MailCopy>> GetExistingMailsAsync(Guid folderId, IEnumerable<UniqueId> uniqueIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using MailKit;
|
||||
using MimeKit;
|
||||
|
||||
namespace Wino.Core.Domain.Models.MailItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates all required information to create a MimeMessage for IMAP synchronizer.
|
||||
/// </summary>
|
||||
public class ImapMessageCreationPackage
|
||||
{
|
||||
public IMessageSummary MessageSummary { get; }
|
||||
public MimeMessage MimeMessage { get; }
|
||||
|
||||
public ImapMessageCreationPackage(IMessageSummary messageSummary, MimeMessage mimeMessage)
|
||||
{
|
||||
MessageSummary = messageSummary;
|
||||
MimeMessage = mimeMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,12 @@ namespace Wino.Core.Domain.Models.Synchronization
|
||||
/// </summary>
|
||||
public List<Guid> SynchronizationFolderIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, additional folders like Sent,Drafts and Deleted will not be synchronized
|
||||
/// with InboxOnly and CustomFolders sync type.
|
||||
/// </summary>
|
||||
public bool ExcludeMustHaveFolders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When doing a linked inbox synchronization, we must ignore reporting completion to the caller for each folder.
|
||||
/// This Id will help tracking that. Id is unique, but this one can be the same for all sync requests
|
||||
@@ -33,6 +39,6 @@ namespace Wino.Core.Domain.Models.Synchronization
|
||||
/// </summary>
|
||||
public Guid? GroupedSynchronizationTrackingId { get; set; }
|
||||
|
||||
public override string ToString() => $"Type: {Type}, Folders: {(SynchronizationFolderIds == null ? "All" : string.Join(",", SynchronizationFolderIds))}";
|
||||
public override string ToString() => $"Type: {Type}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user