The `SendAsync` method in the `MessagingServiceClient` class has been refactored. It no longer uses the `async` keyword and instead directly returns the `Task` from `sender.Send`. This change simplifies the method by removing the `await` operation, while still maintaining asynchronous behavior through the returned `Task`.
34 lines
922 B
C#
34 lines
922 B
C#
#if NET
|
|
using DigitalData.MessagingService.Application.EmailAccounts.Queries;
|
|
using DigitalData.MessagingService.Application.EmailSending.Commands;
|
|
using MediatR;
|
|
|
|
namespace DigitalData.MessagingService.Client;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class MessagingServiceClient(ISender sender)
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="email"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public Task SendAsync(Email email, CancellationToken cancellationToken = default)
|
|
{
|
|
return sender.Send(new PublishEmailViaSmtpCommand()
|
|
{
|
|
Sender = new GetEmailAccountQuery()
|
|
{
|
|
Username = email.From
|
|
},
|
|
Recipients = email.To,
|
|
Subject = email.Subject,
|
|
Body = email.Body,
|
|
IsHtml = email.IsHtml
|
|
}, cancellationToken);
|
|
}
|
|
}
|
|
#endif |