Skip to content

Commit

Permalink
Removed MailFolderCache
Browse files Browse the repository at this point in the history
  • Loading branch information
danzuep committed Aug 1, 2024
1 parent 173e500 commit d0acdd1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 138 deletions.
12 changes: 5 additions & 7 deletions samples/WorkerServiceExample/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,13 @@ private async Task GetMailFolderCacheAsync(string mailFolderFullName = _processe
_logger.LogInformation($"Moved {_imapReceiver} mime message #{messageSummary.UniqueId} to {mailFolderFullName} folder as #{uniqueId}.");
}

public async Task GetMailFolderAsync(string mailFolderName, CancellationToken cancellationToken = default)
public async Task GetMailFolderAsync(string mailFolderFullName, CancellationToken cancellationToken = default)
{
var messageSummary = await GetTopMessageSummaryAsync(cancellationToken);
var mailFolder1 = await _imapReceiver.MailFolderClient.GetFolderAsync(mailFolderFullName, create: true, cancellationToken);
var mailFolder2 = await _imapReceiver.MailFolderClient.GetFolderAsync([mailFolderName], cancellationToken);
var mailFolder3 = await _imapReceiver.ImapClient.Inbox.GetOrCreateSubfolderAsync(mailFolderName, cancellationToken);
var mailFolder4 = await messageSummary.Folder.GetOrCreateSubfolderAsync(mailFolderName, cancellationToken);
//var mimeMessage = await messageSummary.GetMimeMessageAsync(cancellationToken);
_logger.LogInformation($"Mail folder: {mailFolderName}");
var mailFolder1 = await _imapReceiver.MailFolderClient.GetFolderAsync(mailFolderFullName, createIfNotFound: true, cancellationToken);
var mailFolder2 = await _imapReceiver.MailFolderClient.GetFolderAsync([mailFolderFullName], cancellationToken);
var mailFolder3 = await messageSummary.Folder.GetOrCreateSubfolderAsync(mailFolderFullName, cancellationToken);
_logger.LogInformation($"Mail folder: {mailFolderFullName}");
}

private async Task DeleteSeenAsync(CancellationTokenSource cancellationTokenSource)
Expand Down
13 changes: 0 additions & 13 deletions source/MailKitSimplified.Receiver/Abstractions/IMailFolderCache.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ public static class MailFolderExtensions
/// <summary>
/// Get a mail subfolder if it exists, or create it if not.
/// </summary>
/// <param name="mailFolderFullName">Folder name to search for.</param>
/// <param name="baseFolder">Base folder to search in, Inbox by default</param>
/// <param name="mailFolderFullName">Folder name to search for.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Mail folder with a matching name.</returns>
public static async Task<IMailFolder> GetOrCreateSubfolderAsync(this IMailFolder baseFolder, string mailFolderFullName, CancellationToken cancellationToken = default)
{
if (baseFolder == null)
throw new ArgumentNullException(nameof(baseFolder));
if (string.IsNullOrWhiteSpace(mailFolderFullName))
throw new ArgumentNullException(nameof(mailFolderFullName));
IMailFolder mailFolder;
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ private static IServiceCollection AddMailKitSimplifiedEmailReceiver(this IServic
services.AddSingleton<IProtocolLogger, MailKitProtocolLogger>();
services.AddSingleton<IImapReceiverFactory, ImapReceiverFactory>();
services.AddSingleton<IMailFolderMonitorFactory, MailFolderMonitorFactory>();
services.AddSingleton<IMailFolderCache, MailFolderCache>();
services.AddLifetimeServices(serviceLifetime);
return services;
}
Expand Down
113 changes: 0 additions & 113 deletions source/MailKitSimplified.Receiver/Services/MailFolderCache.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ public sealed class MailFolderClient : IMailFolderClient
private ILogger _logger;
private IMailFolder _mailFolder = null;
private IList<string> SentFolderNames;
private readonly IMailFolderCache _mailFolderCache;
private readonly IList<string> DraftsFolderNames;
private readonly IList<string> JunkFolderNames;
private readonly IList<string> TrashFolderNames;
private readonly IImapReceiver _imapReceiver;

public MailFolderClient(IImapReceiver imapReceiver, IOptions<FolderClientOptions> options = null, ILogger<MailFolderClient> logger = null, IMailFolderCache mailFolderCache = null)
public MailFolderClient(IImapReceiver imapReceiver, IOptions<FolderClientOptions> options = null, ILogger<MailFolderClient> logger = null)
{
_logger = logger ?? NullLogger<MailFolderClient>.Instance;
_mailFolderCache = mailFolderCache;
_imapReceiver = imapReceiver ?? throw new ArgumentNullException(nameof(imapReceiver));
SentFolderNames = options?.Value?.SentFolderNames ?? FolderClientOptions.CommonSentFolderNames;
DraftsFolderNames = options?.Value?.DraftsFolderNames ?? FolderClientOptions.CommonDraftsFolderNames;
Expand Down

0 comments on commit d0acdd1

Please sign in to comment.