Refactor: migrate Core -> Domain and reorganize projects

Large refactor that renames/moves core types into a new Govor.Domain surface and reorganizes the Application layer. Models, configurations, migrations and many files moved from Govor.Core/Govor.Data to Govor.Domain; numerous Application services, interfaces and implementations were relocated or added (authentication, friends, messages, medias, push notifications, user sessions, storage, synching, private chats, etc.). Tests updated to use Govor.Domain namespaces and adjusted project references (removed Govor.Data reference from API tests). Also updated API, Hub and mapping code and project files to reflect the new structure and naming. This is primarily a codebase-wide namespace and module reorganization to establish a Domain project and restructure application services.
This commit is contained in:
Artemy
2026-07-16 19:27:45 +07:00
parent 1d35356c8c
commit 6d1c53beeb
371 changed files with 2729 additions and 6694 deletions
@@ -0,0 +1,9 @@
using Govor.Domain.Models;
namespace Govor.Application.PrivateUserChats;
public interface IPrivateChatGroupManager
{
Task AddUsersToPrivateChatGroupAsync(PrivateChat privateChat);
Task RemoveUsersFromPrivateChatGroupAsync(PrivateChat privateChat);
}
@@ -0,0 +1,8 @@
using Govor.Domain.Models;
namespace Govor.Application.PrivateUserChats;
public interface IUserPrivateChatsCreator
{
Task<PrivateChat> CreateAsync(Guid userIdA, Guid userIdB);
}
@@ -0,0 +1,11 @@
using Govor.Domain.Common;
using Govor.Domain.Models;
namespace Govor.Application.PrivateUserChats;
public interface IUserPrivateChatsGetterService
{
Task<List<PrivateChat>> GetUserChatsAsync(Guid userId);
Task<Result<PrivateChat>> GetPrivateChatAsync(Guid chatId);
Task<bool> ExistChatAsync(Guid userIdA, Guid userIdB);
}
@@ -0,0 +1,52 @@
using Govor.Domain;
using Govor.Domain.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace Govor.Application.PrivateUserChats;
public class UserPrivateChatsCreator : IUserPrivateChatsCreator
{
private readonly GovorDbContext _context;
private readonly IPrivateChatGroupManager _privateChatGroupManager;
private readonly ILogger<UserPrivateChatsCreator> _logger;
public UserPrivateChatsCreator(
GovorDbContext context,
IPrivateChatGroupManager privateChatGroupManager,
ILogger<UserPrivateChatsCreator> logger)
{
_context = context;
_privateChatGroupManager = privateChatGroupManager;
_logger = logger;
}
public async Task<PrivateChat> CreateAsync(Guid userIdA, Guid userIdB)
{
var existingChat = await _context.PrivateChats
.FirstOrDefaultAsync(c => (c.UserAId == userIdA && c.UserBId == userIdB) ||
(c.UserAId == userIdB && c.UserBId == userIdA));
if (existingChat is null)
{
var recipientId = Guid.NewGuid();
var privateChat = new PrivateChat
{
Id = recipientId,
UserAId = userIdA,
UserBId = userIdB
};
await _context.PrivateChats.AddAsync(privateChat);
await _context.SaveChangesAsync();
await _privateChatGroupManager.AddUsersToPrivateChatGroupAsync(privateChat);
_logger.LogInformation($"Private chat created with Id: {recipientId} for users {userIdA} and {userIdB}");
return privateChat;
}
_logger.LogInformation($"Private chat already exists for {userIdA} and {userIdB}; Returning existing chat...");
return existingChat;
}
}
@@ -0,0 +1,46 @@
using Govor.Domain;
using Govor.Domain.Common;
using Govor.Domain.Models;
using Microsoft.EntityFrameworkCore;
namespace Govor.Application.PrivateUserChats;
public class UserPrivateChatsGetter : IUserPrivateChatsGetterService
{
private readonly GovorDbContext _context;
public UserPrivateChatsGetter(GovorDbContext context)
{
_context = context;
}
public async Task<List<PrivateChat>> GetUserChatsAsync(Guid userId)
{
return await _context.PrivateChats
.AsNoTracking()
.Where(p => p.UserAId == userId || p.UserBId == userId)
.ToListAsync();
}
public async Task<Result<PrivateChat>> GetPrivateChatAsync(Guid chatId)
{
var res = await _context.PrivateChats.AsNoTracking()
.FirstOrDefaultAsync(p => p.Id == chatId);
if (res == null)
return Result<PrivateChat>.Failure(new Error(nameof(InvalidOperationException),
"PrivateChat not found.")
);
return res;
}
public async Task<bool> ExistChatAsync(Guid userIdA, Guid userIdB)
{
return await _context.PrivateChats
.AsNoTracking()
.AnyAsync(p => (p.UserAId == userIdA && p.UserBId == userIdB) ||
(p.UserBId == userIdA && p.UserAId == userIdB)
);
}
}