Implemented service bus handling of emails and notification processing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Khwezi Mngoma
2026-05-10 16:50:36 +02:00
parent 73ba41beaf
commit cecd9f90e9
6 changed files with 90 additions and 11 deletions
@@ -0,0 +1,18 @@
using LiteCharms.Features.Notifications.Commands;
using static LiteCharms.Abstractions.Constants;
namespace LiteCharms.Features.Email.Events.Handlers;
public class SendShopEmailEnquiryEventHandler(ISender mediator) :
INotificationHandler<SendShopEmailEnquiryEvent>
{
public async ValueTask Handle(SendShopEmailEnquiryEvent notification, CancellationToken cancellationToken)
{
var command = CreateNotificationCommand.Create(Models.NotificationDirection.Outgoing, notification.SenderName!,
notification.SenderAddress!, notification.Subject!, notification.Message!, Models.NotificationPlatforms.Email,
notification.Priority, ShopEmailFromName, ShopEmailFromAddress, Guid.CreateVersion7().ToString(),
Models.CorrelationIdTypes.None, isInternal: true, isHtml: false);
await mediator.Send(command, cancellationToken);
}
}
@@ -0,0 +1,40 @@
using LiteCharms.Abstractions;
using LiteCharms.Models;
namespace LiteCharms.Features.Email.Events;
public class SendShopEmailEnquiryEvent : EventBase, IEvent
{
public string Name { get; set; } = nameof(SendShopEmailEnquiryEvent);
public string? SenderName { get; set; }
public string? SenderAddress { get; set; }
public string? Subject { get; set; }
public string? Message { get; set; }
public Priorities Priority { get; set; }
public SendShopEmailEnquiryEvent() { }
private SendShopEmailEnquiryEvent(string senderName, string senderAddress, string subject, string message, Priorities priority = Priorities.Medium)
{
SenderName = senderName;
SenderAddress = senderAddress;
Subject = subject;
Message = message;
Priority = priority;
}
public static SendShopEmailEnquiryEvent Create(string senderName, string senderAddress, string subject, string message, Priorities priority = Priorities.Medium)
{
ArgumentNullException.ThrowIfNullOrWhiteSpace(senderName, nameof(senderName));
ArgumentNullException.ThrowIfNullOrWhiteSpace(senderAddress, nameof(senderAddress));
ArgumentNullException.ThrowIfNullOrWhiteSpace(subject, nameof(subject));
ArgumentNullException.ThrowIfNullOrWhiteSpace(message, nameof(message));
return new(senderName, senderAddress, subject, message, priority);
}
}