Online Search (#576)

* Very basic online search for gmail.

* Server side of handling offline search and listing part in listing page.

* Default search mode implementation and search UI improvements.

* Online search for Outlook.

* Very basic online search for gmail.

* Server side of handling offline search and listing part in listing page.

* Default search mode implementation and search UI improvements.

* Online search for Outlook.

* Online search for imap without downloading the messages yet. TODO

* Completing imap search.
This commit is contained in:
Burak Kaan Köse
2025-02-22 00:22:00 +01:00
committed by GitHub
parent 42b695854b
commit f61bcb621b
30 changed files with 900 additions and 209 deletions
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MailKit;
using MailKit.Net.Imap;
using Wino.Core.Domain.Entities.Mail;
@@ -17,5 +18,15 @@ public interface IImapSynchronizerStrategy
/// <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="folder">Remote folder to download messages from.</param>
/// <param name="uniqueIdSet">Set of message uniqueids.</param>
/// <param name="cancellationToken">Cancellation token.</param>
Task DownloadMessagesAsync(IImapSynchronizer synchronizer, IMailFolder folder, UniqueIdSet uniqueIdSet, CancellationToken cancellationToken = default);
}
@@ -13,6 +13,14 @@ public interface IMailService
{
Task<MailCopy> GetSingleMailItemAsync(string mailCopyId, string remoteFolderId);
Task<MailCopy> GetSingleMailItemAsync(Guid uniqueMailId);
/// <summary>
/// Returns the single mail item with the given mail copy id.
/// Caution: This method is not safe. Use other overrides.
/// </summary>
/// <param name="mailCopyId"></param>
/// <returns></returns>
Task<MailCopy> GetSingleMailItemAsync(string mailCopyId);
Task<List<IMailItem>> FetchMailsAsync(MailListInitializationOptions options, CancellationToken cancellationToken = default);
/// <summary>
@@ -117,4 +125,14 @@ public interface IMailService
/// <param name="uniqueIds"></param>
/// <returns></returns>
Task<List<MailCopy>> GetExistingMailsAsync(Guid folderId, IEnumerable<UniqueId> uniqueIds);
/// <summary>
/// Creates a new mail from a package without doing any existence check.
/// Use it with caution.
/// </summary>
/// <param name="account">Account that mail belongs to.</param>
/// <param name="mailItemFolder">Assigned folder.</param>
/// <param name="package">Mail creation package.</param>
/// <returns></returns>
Task CreateMailRawAsync(MailAccount account, MailItemFolder mailItemFolder, NewMailItemPackage package);
}
@@ -39,6 +39,17 @@ public interface IPreferencesService
/// </summary>
bool Prefer24HourTimeFormat { get; set; }
/// <summary>
/// Diagnostic ID for the application.
/// Changes per-install.
/// </summary>
string DiagnosticId { get; set; }
/// <summary>
/// Setting: Defines the user's preference of default search mode in mail list.
/// Local search will still offer online search at the end of local search results.
/// </summary>
SearchMode DefaultSearchMode { get; set; }
#endregion
#region Mail
@@ -187,7 +198,7 @@ public interface IPreferencesService
DayOfWeek WorkingDayStart { get; set; }
DayOfWeek WorkingDayEnd { get; set; }
double HourHeight { get; set; }
string DiagnosticId { get; set; }
CalendarSettings GetCurrentCalendarSettings();
@@ -1,6 +1,9 @@
using System.Threading;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MailKit;
using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Models.Folders;
using Wino.Core.Domain.Models.MailItem;
using Wino.Core.Domain.Models.Synchronization;
@@ -35,4 +38,13 @@ public interface IWinoSynchronizerBase : IBaseSynchronizer
/// 3. Dispose all resources.
/// </summary>
Task KillSynchronizerAsync();
/// <summary>
/// Perform online search on the server.
/// </summary>
/// <param name="queryText">Search query.</param>
/// <param name="folders">Folders to include in search. All folders if null.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Search results after downloading missing mail copies from server.</returns>
Task<List<MailCopy>> OnlineSearchAsync(string queryText, List<IMailItemFolder> folders, CancellationToken cancellationToken = default);
}