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,46 @@
using Govor.Application.Interfaces;
using Govor.Core.Models;
using Govor.Core.Repositories.PrivateChats;
using Microsoft.Extensions.Logging;
namespace Govor.Application.Services;
public class UserPrivateChatsCreator : IUserPrivateChatsCreator
{
private readonly IPrivateChatsRepository _privateChats;
private readonly IPrivateChatGroupManager _privateChatGroupManager;
private readonly ILogger<UserPrivateChatsCreator> _logger;
public UserPrivateChatsCreator(
IPrivateChatsRepository privateChats,
IPrivateChatGroupManager privateChatGroupManager,
ILogger<UserPrivateChatsCreator> logger)
{
_privateChats = privateChats;
_privateChatGroupManager = privateChatGroupManager;
_logger = logger;
}
public async Task<PrivateChat> CreateAsync(Guid userIdA, Guid userIdB)
{
if (!_privateChats.Exist(userIdA, userIdB))
{
var recipientId = Guid.NewGuid();
var privateChat = new PrivateChat()
{
Id = recipientId,
UserAId = userIdA,
UserBId = userIdB
};
await _privateChats.AddAsync(privateChat);
await _privateChatGroupManager.AddUsersToPrivateChatGroupAsync(privateChat); // Notifying
_logger.LogInformation($"User for {userIdA} and {userIdB} was created private chat with Id: {recipientId}");
return privateChat;
}
_logger.LogInformation($"Private chat already exists for {userIdA} and {userIdB}; Returning already created chat...");
return await _privateChats.GetByMembersAsync(userIdA, userIdB);
}
}