33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using ContactService.Domain.Events;
|
|
using IM.Commons.IntegrationEvents;
|
|
using MassTransit;
|
|
using MediatR;
|
|
|
|
namespace ContactService.WebApi.Application.EventHandler
|
|
{
|
|
public class FriendAddedHandler : INotificationHandler<FriendAddedDomainEvent>
|
|
{
|
|
private readonly IPublishEndpoint endpoint;
|
|
|
|
public FriendAddedHandler(IPublishEndpoint endpoint)
|
|
{
|
|
this.endpoint = endpoint;
|
|
}
|
|
|
|
public async Task Handle(FriendAddedDomainEvent notification, CancellationToken cancellationToken)
|
|
{
|
|
await endpoint.Publish(new FriendAddedEvent
|
|
{
|
|
OwnerAvatar = notification.Friend.Owner.Avatar,
|
|
OwnerId = notification.Friend.Owner.Id,
|
|
OwnerNickName = notification.Friend.Owner.NickName,
|
|
TargetAvatar = notification.Friend.Target.Avatar,
|
|
TargetId = notification.Friend.Target.Id,
|
|
TargetNickName = notification.Friend.Target.NickName,
|
|
RemarkName = notification.Friend.RemarkName,
|
|
Status = notification.Friend.Status.ToString(),
|
|
}, cancellationToken);
|
|
}
|
|
}
|
|
}
|