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,57 @@
using Govor.Application.Messages.Parameters;
using Microsoft.EntityFrameworkCore;
using Govor.Domain;
using Govor.Domain.Models.Messages;
using Microsoft.Extensions.Logging;
namespace Govor.Application.Messages;
public class MessageEditingService : IMessageEditingService
{
private readonly GovorDbContext _dbContext;
private readonly ILogger<MessageEditingService> _logger;
public MessageEditingService(GovorDbContext dbContext, ILogger<MessageEditingService> logger)
{
_dbContext = dbContext;
_logger = logger;
}
public async Task<EditMessageResult> EditMessageAsync(EditMessage editParams)
{
var message = await _dbContext.Messages
.Include(m => m.MediaAttachments)
.FirstOrDefaultAsync(m => m.Id == editParams.MessageId);
if (message == null)
{
return new EditMessageResult(false, new KeyNotFoundException("Message not found."), null);
}
if (message.SenderId != editParams.EditorId)
{
_logger.LogWarning("User {EditorId} unauthorized to edit message {MessageId}", editParams.EditorId, editParams.MessageId);
return new EditMessageResult(false, new UnauthorizedAccessException("User is not authorized to edit this message."), null);
}
var originalMessageSnapshot = new Message
{
Id = message.Id,
SenderId = message.SenderId,
RecipientId = message.RecipientId,
RecipientType = message.RecipientType,
SentAt = message.SentAt,
ReplyToMessageId = message.ReplyToMessageId,
MediaAttachments = message.MediaAttachments?.ToList() ?? []
};
message.EncryptedContent = editParams.NewContent;
message.IsEdited = true;
message.EditedAt = editParams.EditedAt;
await _dbContext.SaveChangesAsync();
_logger.LogInformation("Message {MessageId} edited successfully.", editParams.MessageId);
return new EditMessageResult(true, null, originalMessageSnapshot);
}
}