was added firebase nitifying

This commit is contained in:
Artemy
2026-03-01 16:48:06 +07:00
parent 76d7280c71
commit eab0d746b8
60 changed files with 2335 additions and 1149 deletions
@@ -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));
}
}
}