IMAP Improvements (#558)
* Fixing an issue where scrollviewer overrides a part of template in mail list. Adjusted zoomed out header grid's corner radius. * IDLE implementation, imap synchronization strategies basics and condstore synchronization. * Adding iCloud and Yahoo as special IMAP handling scenario. * iCloud special imap handling. * Support for killing synchronizers. * Update privacy policy url. * Batching condstore downloads into 50, using SORT extension for searches if supported. * Bumping some nugets. More on the imap synchronizers. * Delegating idle synchronizations to server to post-sync operations. * Update mailkit to resolve qresync bug with iCloud. * Fixing remote highest mode seq checks for qresync and condstore synchronizers. * Yahoo custom settings. * Bump google sdk package. * Fixing the build issue.... * NRE on canceled token accounts during setup. * Server crash handlers. * Remove ARM32. Upgrade server to .NET 9. * Fix icons for yahoo and apple. * Fixed an issue where disabled folders causing an exception on forced sync. * Remove smtp encoding constraint. * Remove commented code. * Fixing merge conflict * Addressing double registrations for mailkit remote folder events in synchronizers. * Making sure idle canceled result is not reported. * Fixing custom imap server dialog opening. * Fixing the issue with account creation making the previously selected account as selected as well. * Fixing app close behavior and logging app close.
This commit is contained in:
@@ -319,6 +319,8 @@ namespace Wino.Services
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ReportUIChange(new AccountRemovedMessage(account));
|
||||
}
|
||||
|
||||
@@ -502,7 +504,7 @@ namespace Wino.Services
|
||||
account.Preferences = preferences;
|
||||
|
||||
// Outlook & Office 365 supports Focused inbox. Enabled by default.
|
||||
bool isMicrosoftProvider = account.ProviderType == MailProviderType.Outlook || account.ProviderType == MailProviderType.Office365;
|
||||
bool isMicrosoftProvider = account.ProviderType == MailProviderType.Outlook;
|
||||
|
||||
// TODO: This should come from account settings API.
|
||||
// Wino doesn't have MailboxSettings yet.
|
||||
|
||||
@@ -5,7 +5,6 @@ using MimeKit;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Services.Extensions;
|
||||
|
||||
namespace Wino.Services.Extensions
|
||||
{
|
||||
@@ -22,6 +21,9 @@ namespace Wino.Services.Extensions
|
||||
throw new ArgumentOutOfRangeException(nameof(mailCopyId), mailCopyId, "Invalid mailCopyId format.");
|
||||
}
|
||||
|
||||
public static UniqueId ResolveUidStruct(string mailCopyId)
|
||||
=> new UniqueId(ResolveUid(mailCopyId));
|
||||
|
||||
public static string CreateUid(Guid folderId, uint messageUid)
|
||||
=> $"{folderId}{MailCopyUidSeparator}{messageUid}";
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Wino.Services
|
||||
if (!string.IsNullOrEmpty(unstickyItem.ParentRemoteFolderId))
|
||||
continue;
|
||||
}
|
||||
else if (account.ProviderType == MailProviderType.Outlook || account.ProviderType == MailProviderType.Office365)
|
||||
else if (account.ProviderType == MailProviderType.Outlook)
|
||||
{
|
||||
bool belongsToExistingParent = await Connection
|
||||
.Table<MailItemFolder>()
|
||||
@@ -367,16 +367,14 @@ namespace Wino.Services
|
||||
|
||||
public async Task<IList<uint>> GetKnownUidsForFolderAsync(Guid folderId)
|
||||
{
|
||||
var folder = await GetFolderAsync(folderId);
|
||||
|
||||
if (folder == null) return default;
|
||||
|
||||
var mailCopyIds = await GetMailCopyIdsByFolderIdAsync(folderId);
|
||||
|
||||
// Make sure we don't include Ids that doesn't have uid separator.
|
||||
// Local drafts might not have it for example.
|
||||
|
||||
return new List<uint>(mailCopyIds.Where(a => a.Contains(MailkitClientExtensions.MailCopyUidSeparator)).Select(a => MailkitClientExtensions.ResolveUid(a)));
|
||||
return new List<uint>(mailCopyIds
|
||||
.Where(a => a.Contains(MailkitClientExtensions.MailCopyUidSeparator))
|
||||
.Select(a => MailkitClientExtensions.ResolveUid(a)));
|
||||
}
|
||||
|
||||
public async Task<MailAccount> UpdateSystemFolderConfigurationAsync(Guid accountId, SystemFolderConfiguration configuration)
|
||||
@@ -546,7 +544,19 @@ namespace Wino.Services
|
||||
{
|
||||
var folders = new List<MailItemFolder>();
|
||||
|
||||
if (options.Type == MailSynchronizationType.FullFolders)
|
||||
if (options.Type == MailSynchronizationType.IMAPIdle)
|
||||
{
|
||||
// Type Inbox will include Sent, Drafts and Deleted folders as well.
|
||||
// For IMAP idle sync, we must include only Inbox folder.
|
||||
|
||||
var inboxFolder = await GetSpecialFolderByAccountIdAsync(options.AccountId, SpecialFolderType.Inbox);
|
||||
|
||||
if (inboxFolder != null)
|
||||
{
|
||||
folders.Add(inboxFolder);
|
||||
}
|
||||
}
|
||||
else if (options.Type == MailSynchronizationType.FullFolders)
|
||||
{
|
||||
// Only get sync enabled folders.
|
||||
|
||||
@@ -570,12 +580,19 @@ namespace Wino.Services
|
||||
}
|
||||
else if (options.Type == MailSynchronizationType.CustomFolders)
|
||||
{
|
||||
// Only get the specified and enabled folders.
|
||||
// Only get the specified folders.
|
||||
|
||||
var synchronizationFolders = await Connection.Table<MailItemFolder>()
|
||||
.Where(a => a.MailAccountId == options.AccountId && options.SynchronizationFolderIds.Contains(a.Id))
|
||||
.Where(a =>
|
||||
a.MailAccountId == options.AccountId &&
|
||||
options.SynchronizationFolderIds.Contains(a.Id))
|
||||
.ToListAsync();
|
||||
|
||||
if (options.ExcludeMustHaveFolders)
|
||||
{
|
||||
return synchronizationFolders;
|
||||
}
|
||||
|
||||
// Order is important for moving.
|
||||
// By implementation, removing mail folders must be synchronized first. Requests are made in that order for custom sync.
|
||||
// eg. Moving item from Folder A to Folder B. If we start syncing Folder B first, we might miss adding assignment for Folder A.
|
||||
|
||||
@@ -984,6 +984,17 @@ namespace Wino.Services
|
||||
public Task<bool> IsMailExistsAsync(string mailCopyId)
|
||||
=> Connection.ExecuteScalarAsync<bool>("SELECT EXISTS(SELECT 1 FROM MailCopy WHERE Id = ?)", mailCopyId);
|
||||
|
||||
public async Task<List<MailCopy>> GetExistingMailsAsync(Guid folderId, IEnumerable<MailKit.UniqueId> uniqueIds)
|
||||
{
|
||||
var localMailIds = uniqueIds.Where(a => a != null).Select(a => MailkitClientExtensions.CreateUid(folderId, a.Id)).ToArray();
|
||||
|
||||
var query = new Query(nameof(MailCopy))
|
||||
.WhereIn("Id", localMailIds)
|
||||
.GetRawQuery();
|
||||
|
||||
return await Connection.QueryAsync<MailCopy>(query);
|
||||
}
|
||||
|
||||
public Task<bool> IsMailExistsAsync(string mailCopyId, Guid folderId)
|
||||
=> Connection.ExecuteScalarAsync<bool>("SELECT EXISTS(SELECT 1 FROM MailCopy WHERE Id = ? AND FolderId = ?)", mailCopyId, folderId);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Wino.Services
|
||||
services.AddTransient<IContactService, ContactService>();
|
||||
services.AddTransient<ISignatureService, SignatureService>();
|
||||
services.AddTransient<IContextMenuItemService, ContextMenuItemService>();
|
||||
services.AddTransient<ISpecialImapProviderConfigResolver, SpecialImapProviderConfigResolver>();
|
||||
|
||||
services.AddSingleton<IThreadingStrategyProvider, ThreadingStrategyProvider>();
|
||||
services.AddTransient<IOutlookThreadingStrategy, OutlookThreadingStrategy>();
|
||||
|
||||
68
Wino.Services/SpecialImapProviderConfigResolver.cs
Normal file
68
Wino.Services/SpecialImapProviderConfigResolver.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Accounts;
|
||||
|
||||
namespace Wino.Services
|
||||
{
|
||||
public class SpecialImapProviderConfigResolver : ISpecialImapProviderConfigResolver
|
||||
{
|
||||
private readonly CustomServerInformation iCloudServerConfig = new CustomServerInformation()
|
||||
{
|
||||
IncomingServer = "imap.mail.me.com",
|
||||
IncomingServerPort = "993",
|
||||
IncomingServerType = CustomIncomingServerType.IMAP4,
|
||||
IncomingServerSocketOption = ImapConnectionSecurity.Auto,
|
||||
IncomingAuthenticationMethod = ImapAuthenticationMethod.Auto,
|
||||
OutgoingServer = "smtp.mail.me.com",
|
||||
OutgoingServerPort = "587",
|
||||
OutgoingServerSocketOption = ImapConnectionSecurity.Auto,
|
||||
OutgoingAuthenticationMethod = ImapAuthenticationMethod.Auto,
|
||||
MaxConcurrentClients = 5,
|
||||
};
|
||||
|
||||
private readonly CustomServerInformation yahooServerConfig = new CustomServerInformation()
|
||||
{
|
||||
IncomingServer = "imap.mail.yahoo.com",
|
||||
IncomingServerPort = "993",
|
||||
IncomingServerType = CustomIncomingServerType.IMAP4,
|
||||
IncomingServerSocketOption = ImapConnectionSecurity.Auto,
|
||||
IncomingAuthenticationMethod = ImapAuthenticationMethod.Auto,
|
||||
OutgoingServer = "smtp.mail.yahoo.com",
|
||||
OutgoingServerPort = "587",
|
||||
OutgoingServerSocketOption = ImapConnectionSecurity.Auto,
|
||||
OutgoingAuthenticationMethod = ImapAuthenticationMethod.Auto,
|
||||
MaxConcurrentClients = 5,
|
||||
};
|
||||
|
||||
|
||||
public CustomServerInformation GetServerInformation(MailAccount account, AccountCreationDialogResult dialogResult)
|
||||
{
|
||||
CustomServerInformation resolvedConfig = null;
|
||||
|
||||
if (dialogResult.SpecialImapProviderDetails.SpecialImapProvider == SpecialImapProvider.iCloud)
|
||||
{
|
||||
resolvedConfig = iCloudServerConfig;
|
||||
|
||||
// iCloud takes username before the @icloud part for incoming, but full address as outgoing.
|
||||
resolvedConfig.IncomingServerUsername = dialogResult.SpecialImapProviderDetails.Address.Split('@')[0];
|
||||
resolvedConfig.OutgoingServerUsername = dialogResult.SpecialImapProviderDetails.Address;
|
||||
}
|
||||
else if (dialogResult.SpecialImapProviderDetails.SpecialImapProvider == SpecialImapProvider.Yahoo)
|
||||
{
|
||||
resolvedConfig = yahooServerConfig;
|
||||
|
||||
// Yahoo uses full address for both incoming and outgoing.
|
||||
resolvedConfig.IncomingServerUsername = dialogResult.SpecialImapProviderDetails.Address;
|
||||
resolvedConfig.OutgoingServerUsername = dialogResult.SpecialImapProviderDetails.Address;
|
||||
}
|
||||
|
||||
// Fill in account details.
|
||||
resolvedConfig.Address = dialogResult.SpecialImapProviderDetails.Address;
|
||||
resolvedConfig.IncomingServerPassword = dialogResult.SpecialImapProviderDetails.Password;
|
||||
resolvedConfig.OutgoingServerPassword = dialogResult.SpecialImapProviderDetails.Password;
|
||||
resolvedConfig.DisplayName = dialogResult.SpecialImapProviderDetails.SenderName;
|
||||
return resolvedConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace Wino.Services
|
||||
{
|
||||
return mailProviderType switch
|
||||
{
|
||||
MailProviderType.Outlook or MailProviderType.Office365 => _outlookThreadingStrategy,
|
||||
MailProviderType.Outlook => _outlookThreadingStrategy,
|
||||
MailProviderType.Gmail => _gmailThreadingStrategy,
|
||||
_ => _imapThreadStrategy,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user