Mail queues.

This commit is contained in:
Burak Kaan Köse
2025-10-30 17:15:05 +01:00
parent b0ac6e4e55
commit 2d81d07c0a
13 changed files with 579 additions and 472 deletions
+2 -1
View File
@@ -59,7 +59,8 @@ public class DatabaseService : IDatabaseService
typeof(CalendarItem),
typeof(Reminder),
typeof(Thumbnail),
typeof(KeyboardShortcut)
typeof(KeyboardShortcut),
typeof(MailItemQueue)
);
}
}
+42
View File
@@ -697,6 +697,11 @@ public class MailService : BaseDatabaseService, IMailService
await Task.WhenAll(mimeSaveTask, contactSaveTask, insertMailTask).ConfigureAwait(false);
}
public async Task CreateMailAsyncEx(Guid accountId, NewMailItemPackage package)
{
}
public async Task<bool> CreateMailAsync(Guid accountId, NewMailItemPackage package)
{
var account = await _accountService.GetAccountAsync(accountId).ConfigureAwait(false);
@@ -784,6 +789,43 @@ public class MailService : BaseDatabaseService, IMailService
}
}
#region Mail Queue
public Task ClearMailItemQueueAsync(Guid accountId)
=> Connection.ExecuteAsync("DELETE FROM MailItemQueue WHERE AccountId = ?", accountId);
public Task<int> GetMailItemQueueCountAsync(Guid accountId)
=> Connection.Table<MailItemQueue>().Where(a => a.AccountId == accountId).CountAsync();
public Task UpdateMailItemQueueAsync(IEnumerable<MailItemQueue> queueItems)
{
if (queueItems == null || !queueItems.Any())
return Task.CompletedTask;
return Connection.UpdateAllAsync(queueItems);
}
public Task AddMailItemQueueItemsAsync(IEnumerable<MailItemQueue> queueItems)
{
if (queueItems == null || !queueItems.Any())
return Task.CompletedTask;
return Connection.InsertAllAsync(queueItems);
}
public Task<List<MailItemQueue>> GetMailItemQueueAsync(Guid accountId, int take)
{
// Skip not needed. Items are removed as they are processed.
return Connection.Table<MailItemQueue>()
.Where(a => a.AccountId == accountId && !a.IsProcessed)
.OrderBy(a => a.CreatedAt)
.Take(take)
.ToListAsync();
}
#endregion
private async Task<MimeMessage> CreateDraftMimeAsync(MailAccount account, DraftCreationOptions draftCreationOptions)
{
// This unique id is stored in mime headers for Wino to identify remote message with local copy.