Skip to content

Commit

Permalink
batch send
Browse files Browse the repository at this point in the history
  • Loading branch information
coronabytes committed Feb 4, 2024
1 parent d5e8821 commit eb3209f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Core.Email.Abstractions/ICoreEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public interface ICoreEmail
{
public Task<CoreEmailStatus> SendAsync(CoreEmailMessage message, CancellationToken cancellationToken = default);
public Task<IReadOnlyCollection<CoreEmailStatus>> SendAsync(List<CoreEmailMessage> message, CancellationToken cancellationToken = default);
}
10 changes: 10 additions & 0 deletions Core.Email/CoreEmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ public async Task<CoreEmailStatus> SendAsync(CoreEmailMessage message,
return (await provider.SendBatchAsync([message], cancellationToken)).First();
}

public async Task<IReadOnlyCollection<CoreEmailStatus>> SendAsync(List<CoreEmailMessage> messages, CancellationToken cancellationToken = default)
{
if (_defaultProvider == null)
throw new InvalidOperationException($"provider \"Default\" not found");

var res = await _defaultProvider.SendBatchAsync(messages, cancellationToken);

return res;
}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
if (_persistence == null)
Expand Down

0 comments on commit eb3209f

Please sign in to comment.