Skip to content

Commit

Permalink
solve Olive.Email package error
Browse files Browse the repository at this point in the history
  • Loading branch information
GeeksAmin committed Aug 15, 2023
1 parent f79b930 commit 5bb7609
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Olive.Email/Email.Sending/EmailOutbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEmailMessage>();

Log.Info($"Loaded {toSend.Count()} emails to send ...");

Expand Down
13 changes: 9 additions & 4 deletions Olive.Email/Email.Sending/EmailRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ public EmailRepository(IConfiguration config)
Config = config.GetSection("Email").Get<EmailConfiguration>();
}

public async Task<IEnumerable<IEmailMessage>> GetUnsentEmails()
public async Task<IEnumerable<T>> GetUnsentEmails<T>() where T : IEmailMessage
{
var unsentEmails = await Database.GetList<IEmailMessage>()
.Where(x => x.Retries < Config.MaxRetries);
return unsentEmails.OrderBy(x => x.SendableDate);
var records = await Database.GetList<T>();
var result = records
.OfType<Entity>()
.Cast<T>()
.Where(x => x.Retries < Config.MaxRetries)
.OrderBy(x => x.SendableDate);

return result;
}

public async Task<IEnumerable<T>> GetSentEmails<T>() where T : IEmailMessage
Expand Down
2 changes: 1 addition & 1 deletion Olive.Email/Email.Sending/IEmailRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Olive.Email
public interface IEmailRepository
{
/// <summary>Gets all emails ready to be sent.</summary>
Task<IEnumerable<IEmailMessage>> GetUnsentEmails();
Task<IEnumerable<T>> GetUnsentEmails<T>() where T : IEmailMessage;

/// <summary>Gets all emails that have been sent</summary>
Task<IEnumerable<T>> GetSentEmails<T>() where T : IEmailMessage;
Expand Down
2 changes: 1 addition & 1 deletion Olive.Email/Olive.Email.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>3.1.116</Version>
<Version>3.1.118</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Olive.Entities.Data/Database/Database.GetList.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq.Expressions;
using System.Net.Mail;
using System.Threading.Tasks;

namespace Olive.Entities.Data
Expand Down

0 comments on commit 5bb7609

Please sign in to comment.