refactor: Rename EmailPorifler to MessagingService
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using DigitalData.MessagingService.Application.EmailSending.Commands;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DigitalData.MessagingService.API.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Email sending API controller
|
||||
/// Enqueues outgoing emails to RabbitMQ for async processing
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class EmailsController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Send email (enqueue to RabbitMQ for background processing)
|
||||
/// </summary>
|
||||
/// <param name="command">Send email command</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>HTTP 202 Accepted (queued for processing)</returns>
|
||||
[HttpPost("send")]
|
||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> SendEmail([FromBody] SendEmailCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var outgoingEmailEvent = await mediator.Send(command, cancellationToken);
|
||||
|
||||
return Accepted(new
|
||||
{
|
||||
CommandId = outgoingEmailEvent.Id,
|
||||
To = outgoingEmailEvent.Recipient,
|
||||
outgoingEmailEvent.Subject,
|
||||
outgoingEmailEvent.QueuedAt
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user