feat(client): add MessagingServiceClient and dependency injection extensions

Introduce the Email contract and MessagingServiceClient that send mail through the Application layer via MediatR, and add AddMessagingServiceClient overloads for delegate- and IConfiguration-based setup. Remove the empty client DI placeholders.
This commit is contained in:
2026-11-04 14:53:17 +01:00
parent eed9a0e915
commit 034d81f7f6
5 changed files with 118 additions and 20 deletions

View File

@@ -0,0 +1,34 @@
#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 async Task SendAsync(Email email, CancellationToken cancellationToken = default)
{
await sender.Send(new PublishEmailViaSmtpCommand()
{
Sender = new GetEmailAccountQuery()
{
Username = email.From
},
Recipients = email.To,
Subject = email.Subject,
Body = email.Body,
IsHtml = email.IsHtml
}, cancellationToken);
}
}
#endif