Make sure there are no duplicate items for providers except Gmail when creating mails.

This commit is contained in:
Burak Kaan Köse
2025-04-04 23:55:50 +02:00
parent c6048aea80
commit 83be587c1a

View File

@@ -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;