Files
Govor/Govor.Application/Services/Messages/MessagesLoader.cs
T
Artemy 65a43c09d3 Refactor message service and move tests to Application.Tests
Renamed IMessageService to IMessageCommandService and updated all usages accordingly. Moved and renamed test files from Govor.API.Tests to the new Govor.Application.Tests project, updating namespaces to match. Refactored message-related services and controllers to use the new naming and structure. Added Govor.Application.Tests project to the solution.
2025-07-10 18:05:10 +07:00

43 lines
1.5 KiB
C#

using Govor.Application.Interfaces;
using Govor.Core.Models;
using Govor.Core.Repositories.Groups;
using Govor.Core.Repositories.Messages;
using Govor.Data.Repositories.Exceptions;
namespace Govor.Application.Services.Messages;
public class MessagesLoader : IMessagesLoader
{
private IVerifyFriendship _friendship;
private IGroupsRepository _groupsRepository;
private IMessagesRepository _messagesRepository;
public async Task<List<Message>> LoadLastMessagesInUserChat(Guid userId, Guid currentUser, Guid? startMessageId, int pageSize = 20)
{
await _friendship.VerifyAsync(userId, currentUser);
try
{
throw new NotImplementedException();
//return await _groups.GetMessages(userId, startMessageId, pageSize);
}
catch (NotFoundException ex)
{
return new List<Message>();
}
}
public async Task<List<Message>> LoadLastMessagesInChatGroup(Guid chatId, Guid currentUser, Guid? startMessageId, int pageSize = 20)
{
if(!await _groupsRepository.IsUserMemberOfGroupAsync(currentUser, chatId))
throw new UnauthorizedAccessException("You are not in a group.");
try
{
throw new NotImplementedException();
//return await _groups.GetMessages(chatId, startMessageId, pageSize, RecipientType.Group);
}
catch (NotFoundException ex)
{
return new List<Message>();
}
}
}