diff --git a/Olive.Email/Email.Sending/EmailOutbox.cs b/Olive.Email/Email.Sending/EmailOutbox.cs index b66c0f35f..5f9c0c133 100644 --- a/Olive.Email/Email.Sending/EmailOutbox.cs +++ b/Olive.Email/Email.Sending/EmailOutbox.cs @@ -52,7 +52,7 @@ public async Task SendAll(TimeSpan? delayPerSend = null) async Task DoSendAll(TimeSpan? delayPerSend) { - var toSend = await Repository.GetUnsentEmails(); + var toSend = await Repository.GetUnsentEmails(); Log.Info($"Loaded {toSend.Count()} emails to send ..."); diff --git a/Olive.Email/Email.Sending/EmailRepository.cs b/Olive.Email/Email.Sending/EmailRepository.cs index 5dd49c519..f42b69f0f 100644 --- a/Olive.Email/Email.Sending/EmailRepository.cs +++ b/Olive.Email/Email.Sending/EmailRepository.cs @@ -18,11 +18,16 @@ public EmailRepository(IConfiguration config) Config = config.GetSection("Email").Get(); } - public async Task> GetUnsentEmails() + public async Task> GetUnsentEmails() where T : IEmailMessage { - var unsentEmails = await Database.GetList() - .Where(x => x.Retries < Config.MaxRetries); - return unsentEmails.OrderBy(x => x.SendableDate); + var records = await Database.GetList(); + var result = records + .OfType() + .Cast() + .Where(x => x.Retries < Config.MaxRetries) + .OrderBy(x => x.SendableDate); + + return result; } public async Task> GetSentEmails() where T : IEmailMessage diff --git a/Olive.Email/Email.Sending/IEmailRepository.cs b/Olive.Email/Email.Sending/IEmailRepository.cs index 9aa9d1ff0..cfe317ef5 100644 --- a/Olive.Email/Email.Sending/IEmailRepository.cs +++ b/Olive.Email/Email.Sending/IEmailRepository.cs @@ -11,7 +11,7 @@ namespace Olive.Email public interface IEmailRepository { /// Gets all emails ready to be sent. - Task> GetUnsentEmails(); + Task> GetUnsentEmails() where T : IEmailMessage; /// Gets all emails that have been sent Task> GetSentEmails() where T : IEmailMessage; diff --git a/Olive.Email/Olive.Email.csproj b/Olive.Email/Olive.Email.csproj index 6e0443cb2..f1731b7b6 100644 --- a/Olive.Email/Olive.Email.csproj +++ b/Olive.Email/Olive.Email.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 3.1.116 + 3.1.118 diff --git a/Olive.Entities.Data/Database/Database.GetList.cs b/Olive.Entities.Data/Database/Database.GetList.cs index 8e99986db..a7af06ef8 100644 --- a/Olive.Entities.Data/Database/Database.GetList.cs +++ b/Olive.Entities.Data/Database/Database.GetList.cs @@ -1,5 +1,6 @@ using System; using System.Linq.Expressions; +using System.Net.Mail; using System.Threading.Tasks; namespace Olive.Entities.Data