Revert "提交"

This reverts commit b96d895809.
This commit is contained in:
2026-02-12 21:59:08 +08:00
parent b96d895809
commit d429560511
339 changed files with 46657 additions and 46655 deletions
@@ -1,21 +1,21 @@
using IM_API.Domain.Events;
using IM_API.Interface.Services;
using MassTransit;
namespace IM_API.Application.EventHandlers.GroupJoinHandler
{
public class GroupJoinConversationHandler : IConsumer<GroupJoinEvent>
{
private IConversationService _conversationService;
public GroupJoinConversationHandler(IConversationService conversationService)
{
_conversationService = conversationService;
}
public async Task Consume(ConsumeContext<GroupJoinEvent> context)
{
var @event = context.Message;
await _conversationService.MakeConversationAsync(@event.UserId, @event.GroupId, Models.ChatType.GROUP);
}
}
}
using IM_API.Domain.Events;
using IM_API.Interface.Services;
using MassTransit;
namespace IM_API.Application.EventHandlers.GroupJoinHandler
{
public class GroupJoinConversationHandler : IConsumer<GroupJoinEvent>
{
private IConversationService _conversationService;
public GroupJoinConversationHandler(IConversationService conversationService)
{
_conversationService = conversationService;
}
public async Task Consume(ConsumeContext<GroupJoinEvent> context)
{
var @event = context.Message;
await _conversationService.MakeConversationAsync(@event.UserId, @event.GroupId, Models.ChatType.GROUP);
}
}
}
@@ -1,22 +1,22 @@
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);
}
}
}
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);
}
}
}
@@ -1,45 +1,45 @@
using IM_API.Domain.Events;
using IM_API.Dtos;
using IM_API.Hubs;
using IM_API.Tools;
using IM_API.VOs.Group;
using MassTransit;
using Microsoft.AspNetCore.SignalR;
using StackExchange.Redis;
namespace IM_API.Application.EventHandlers.GroupJoinHandler
{
public class GroupJoinSignalrHandler : IConsumer<GroupJoinEvent>
{
private readonly IHubContext<ChatHub> _hub;
private readonly IDatabase _redis;
public GroupJoinSignalrHandler(IHubContext<ChatHub> hub, IConnectionMultiplexer connectionMultiplexer)
{
_hub = hub;
_redis = connectionMultiplexer.GetDatabase();
}
public async Task Consume(ConsumeContext<GroupJoinEvent> context)
{
var @event = context.Message;
string stramKey = StreamKeyBuilder.Group(@event.GroupId);
//将用户加入群组通知
var list = await _redis.SetMembersAsync(RedisKeys.GetConnectionIdKey(@event.UserId.ToString()));
if(list != null && list.Length > 0)
{
var tasks = list.Select(connectionId =>
_hub.Groups.AddToGroupAsync(connectionId!, stramKey)
).ToList();
await Task.WhenAll(tasks);
}
//发送通知给群成员
var msg = new GroupJoinVo
{
GroupId = @event.GroupId,
UserId = @event.UserId
};
await _hub.Clients.Group(stramKey).SendAsync("ReceiveMessage",new HubResponse<GroupJoinVo>("Event",msg));
}
}
}
using IM_API.Domain.Events;
using IM_API.Dtos;
using IM_API.Hubs;
using IM_API.Tools;
using IM_API.VOs.Group;
using MassTransit;
using Microsoft.AspNetCore.SignalR;
using StackExchange.Redis;
namespace IM_API.Application.EventHandlers.GroupJoinHandler
{
public class GroupJoinSignalrHandler : IConsumer<GroupJoinEvent>
{
private readonly IHubContext<ChatHub> _hub;
private readonly IDatabase _redis;
public GroupJoinSignalrHandler(IHubContext<ChatHub> hub, IConnectionMultiplexer connectionMultiplexer)
{
_hub = hub;
_redis = connectionMultiplexer.GetDatabase();
}
public async Task Consume(ConsumeContext<GroupJoinEvent> context)
{
var @event = context.Message;
string stramKey = StreamKeyBuilder.Group(@event.GroupId);
//将用户加入群组通知
var list = await _redis.SetMembersAsync(RedisKeys.GetConnectionIdKey(@event.UserId.ToString()));
if(list != null && list.Length > 0)
{
var tasks = list.Select(connectionId =>
_hub.Groups.AddToGroupAsync(connectionId!, stramKey)
).ToList();
await Task.WhenAll(tasks);
}
//发送通知给群成员
var msg = new GroupJoinVo
{
GroupId = @event.GroupId,
UserId = @event.UserId
};
await _hub.Clients.Group(stramKey).SendAsync("ReceiveMessage",new HubResponse<GroupJoinVo>("Event",msg));
}
}
}