femto-backend/Femto.Modules.Auth/Models/DomainEventHandlers/UserWasCreatedHandler.cs
2025-05-17 23:47:19 +02:00

20 lines
665 B
C#

using Femto.Common.Infrastructure.Outbox;
using Femto.Modules.Auth.Contracts.Events;
using Femto.Modules.Auth.Data;
using Femto.Modules.Auth.Models.Events;
using MediatR;
namespace Femto.Modules.Auth.Models.DomainEventHandlers;
internal class UserWasCreatedHandler(Outbox<AuthContext> outbox)
: INotificationHandler<UserWasCreatedEvent>
{
public async Task Handle(UserWasCreatedEvent notification, CancellationToken cancellationToken)
{
await outbox.AddMessage(
notification.User.Id,
new UserWasCreatedIntegrationEvent(notification.User.Id, notification.User.Username),
cancellationToken
);
}
}