23 lines
747 B
C#
23 lines
747 B
C#
using IM_API.Domain.Events;
|
|
using IM_API.Interface.Services;
|
|
using MassTransit;
|
|
|
|
namespace IM_API.Application.EventHandlers.GroupJoinHandler
|
|
{
|
|
public class GroupJoinDbHandler : IConsumer<GroupJoinEvent>
|
|
{
|
|
private readonly IGroupService _groupService;
|
|
public GroupJoinDbHandler(IGroupService groupService)
|
|
{
|
|
_groupService = groupService;
|
|
}
|
|
|
|
public async Task Consume(ConsumeContext<GroupJoinEvent> context)
|
|
{
|
|
await _groupService.MakeGroupMemberAsync(context.Message.UserId,
|
|
context.Message.GroupId, context.Message.IsCreated ?
|
|
Models.GroupMemberRole.Master : Models.GroupMemberRole.Normal);
|
|
}
|
|
}
|
|
}
|