19 lines
644 B
C#
19 lines
644 B
C#
using Femto.Modules.Blog.Contracts.Events;
|
|
using Femto.Modules.Blog.Domain.Posts.Events;
|
|
using Femto.Modules.Blog.Infrastructure.Integration;
|
|
using MediatR;
|
|
|
|
namespace Femto.Modules.Blog.Domain.Posts.Handlers;
|
|
|
|
internal class PostCreatedHandler(Outbox outbox) : INotificationHandler<PostCreated>
|
|
{
|
|
public async Task Handle(PostCreated notification, CancellationToken cancellationToken)
|
|
{
|
|
var post = notification.Post;
|
|
await outbox.AddMessage(
|
|
post.Id,
|
|
new PostCreatedIntegrationEvent(Guid.CreateVersion7(), post.Id, post.Media.Select(m => m.Id)),
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|