From d57fd20ca25c217df7df009917dc64efb4a634f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Sun, 16 Jun 2024 23:18:21 +0200 Subject: [PATCH] Fixed a crash for IMAP when there are no sent and draft folder set. --- Wino.Core/Integration/Threading/ImapThreadStrategy.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Wino.Core/Integration/Threading/ImapThreadStrategy.cs b/Wino.Core/Integration/Threading/ImapThreadStrategy.cs index 0a2d7da8..97aded37 100644 --- a/Wino.Core/Integration/Threading/ImapThreadStrategy.cs +++ b/Wino.Core/Integration/Threading/ImapThreadStrategy.cs @@ -25,7 +25,7 @@ namespace Wino.Core.Integration.Threading private Task GetReplyParentAsync(IMailItem replyItem, Guid accountId, Guid threadingFolderId, Guid sentFolderId, Guid draftFolderId) { if (string.IsNullOrEmpty(replyItem?.MessageId)) return Task.FromResult(null); - + var query = new Query("MailCopy") .Distinct() .Take(1) @@ -61,7 +61,7 @@ namespace Wino.Core.Integration.Threading public async Task> ThreadItemsAsync(List items) { var threads = new List(); - + var account = items.First().AssignedAccount; var accountId = account.Id; @@ -77,7 +77,9 @@ namespace Wino.Core.Integration.Threading var sentFolder = await _folderService.GetSpecialFolderByAccountIdAsync(accountId, Domain.Enums.SpecialFolderType.Sent); var draftFolder = await _folderService.GetSpecialFolderByAccountIdAsync(accountId, Domain.Enums.SpecialFolderType.Draft); - if (sentFolder == null || draftFolder == null) return default; + // Threading is not possible. Return items as it is. + + if (sentFolder == null || draftFolder == null) return new List(items); foreach (var replyItem in items) { @@ -134,7 +136,7 @@ namespace Wino.Core.Integration.Threading if (mailLookupTable.ContainsKey(replyToParent.Id)) mailLookupTable[replyToParent.Id] = true; - + replyToParent = await GetInReplyToReplyAsync(replyToParent, accountId, replyToParent.AssignedFolder.Id, sentFolder.Id, draftFolder.Id); }