From 83be587c1a0d12f69cb229b426a4d4a6356f3045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Fri, 4 Apr 2025 23:55:50 +0200 Subject: [PATCH] Make sure there are no duplicate items for providers except Gmail when creating mails. --- Wino.Services/MailService.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Wino.Services/MailService.cs b/Wino.Services/MailService.cs index ebb9c821..6de9fe22 100644 --- a/Wino.Services/MailService.cs +++ b/Wino.Services/MailService.cs @@ -726,7 +726,7 @@ public class MailService : BaseDatabaseService, IMailService // but only single MIME to represent all. // Save mime file to disk. - var isMimeExists = await _mimeFileService.IsMimeExistAsync(accountId, mailCopy.FileId); + var isMimeExists = await _mimeFileService.IsMimeExistAsync(accountId, mailCopy.FileId).ConfigureAwait(false); if (!isMimeExists) { @@ -757,6 +757,14 @@ public class MailService : BaseDatabaseService, IMailService } else { + if (account.ProviderType != MailProviderType.Gmail) + { + // Make sure there is only 1 instance left of this mail copy id. + var allMails = await GetMailItemsAsync(mailCopy.Id).ConfigureAwait(false); + + await DeleteMailAsync(accountId, mailCopy.Id).ConfigureAwait(false); + } + await InsertMailAsync(mailCopy).ConfigureAwait(false); return true;