mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
was added firebase nitifying
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Govor.API.Hubs;
|
||||
using Govor.API.Hubs.Infrastructure;
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Core.Models;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Govor.API.Hubs.Infrastructure;
|
||||
|
||||
public class PrivateChatGroupManager : IPrivateChatGroupManager
|
||||
{
|
||||
private readonly IConnectionStore _connectionStore;
|
||||
private readonly IHubContext<ChatsHub> _hubContext;
|
||||
|
||||
public PrivateChatGroupManager(IConnectionStore connectionStore, IHubContext<ChatsHub> hubContext)
|
||||
{
|
||||
_connectionStore = connectionStore;
|
||||
_hubContext = hubContext;
|
||||
}
|
||||
|
||||
public async Task AddUsersToPrivateChatGroupAsync(PrivateChat privateChat)
|
||||
{
|
||||
var connectionsA = _connectionStore.GetConnections(privateChat.UserAId);
|
||||
var connectionsB = _connectionStore.GetConnections(privateChat.UserBId);
|
||||
|
||||
foreach (var conn in connectionsA.Concat(connectionsB))
|
||||
{
|
||||
await _hubContext.Groups.AddToGroupAsync(conn, ChatHubConstants.GetPrivateChat(privateChat.Id));
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RemoveUsersFromPrivateChatGroupAsync(PrivateChat privateChat)
|
||||
{
|
||||
var connectionsA = _connectionStore.GetConnections(privateChat.UserAId);
|
||||
var connectionsB = _connectionStore.GetConnections(privateChat.UserBId);
|
||||
|
||||
foreach (var conn in connectionsA.Concat(connectionsB))
|
||||
{
|
||||
await _hubContext.Groups.RemoveFromGroupAsync(conn, ChatHubConstants.GetPrivateChat(privateChat.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user