From 70515e225291b38a22a0309012cce81e35a7ac14 Mon Sep 17 00:00:00 2001
From: Daniel Collingwood <82693586+danzuep@users.noreply.github.com>
Date: Wed, 20 Sep 2023 09:42:04 +0800
Subject: [PATCH] UniqueId always included in Items filter
---
source/MailKitSimplified.Receiver/Abstractions/IMailReader.cs | 2 +-
.../MailKitSimplified.Receiver/Services/MailFolderReader.cs | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/source/MailKitSimplified.Receiver/Abstractions/IMailReader.cs b/source/MailKitSimplified.Receiver/Abstractions/IMailReader.cs
index 256346e..4bf0f90 100644
--- a/source/MailKitSimplified.Receiver/Abstractions/IMailReader.cs
+++ b/source/MailKitSimplified.Receiver/Abstractions/IMailReader.cs
@@ -53,7 +53,7 @@ public interface IMailReader
IMailReader Query(SearchQuery searchQuery);
///
- /// Set a which message summary parts to fetch.
+ /// Set which message summary parts to fetch. UniqueId is always included.
///
/// Message summary item filter.
/// Fluent .
diff --git a/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs b/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs
index fd095ae..5342a4c 100644
--- a/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs
+++ b/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs
@@ -143,7 +143,7 @@ public IMailReader Query(SearchQuery searchQuery)
public IMailReader Items(MessageSummaryItems messageSummaryItems)
{
- _messageSummaryItems = messageSummaryItems;
+ _messageSummaryItems = messageSummaryItems | MessageSummaryItems.UniqueId;
return this;
}
@@ -217,7 +217,6 @@ private async Task> GetMessageSummariesAsync(IMailFolder
return Array.Empty();
}
IList filteredSummaries;
- filter |= MessageSummaryItems.UniqueId;
if (_uniqueIds != null)
{
filteredSummaries = await mailFolder.FetchAsync(_uniqueIds, filter, cancellationToken).ConfigureAwait(false);
@@ -269,6 +268,7 @@ public async Task> GetMessageSummariesAsync(MessageSummar
_logger.LogInformation("Take(0) means no results will be returned.");
return Array.Empty();
}
+ filter |= MessageSummaryItems.UniqueId;
(var mailFolder, var closeWhenFinished) = await OpenMailFolderAsync(cancellationToken).ConfigureAwait(false);
var messageSummaries = await GetMessageSummariesAsync(mailFolder, filter, cancellationToken).ConfigureAwait(false);
await CloseMailFolderAsync(mailFolder, closeWhenFinished, messageSummaries.Count).ConfigureAwait(false);