mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
test to make server
This commit is contained in:
@@ -51,12 +51,22 @@ public class MessageCommandService : IMessageCommandService
|
||||
{
|
||||
if (!await _usersRepository.ExistsByIdAsync(sendParams.RecipientId))
|
||||
{
|
||||
_logger.LogWarning("Attempt to send message to non-existent user {RecipientId}", sendParams.RecipientId);
|
||||
return new SendMessageResult(false, new KeyNotFoundException($"Recipient user {sendParams.RecipientId} not found."), default);
|
||||
if (!_privateChats.Exist(sendParams.RecipientId))
|
||||
{
|
||||
_logger.LogWarning("Attempt to send message to non-existent user {RecipientId}", sendParams.RecipientId);
|
||||
return new SendMessageResult(false, new KeyNotFoundException($"Recipient user {sendParams.RecipientId} not found."), default);
|
||||
}
|
||||
else
|
||||
{
|
||||
recipientId = sendParams.RecipientId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verify friendship for private messages
|
||||
await _verifyFriendship.VerifyAsync(sendParams.FromUserId, sendParams.RecipientId);
|
||||
recipientId = await GetPrivateChatsIdAsync(sendParams.FromUserId, sendParams.RecipientId);
|
||||
}
|
||||
// Verify friendship for private messages
|
||||
await _verifyFriendship.VerifyAsync(sendParams.FromUserId, sendParams.RecipientId);
|
||||
recipientId = await GetPrivateChatsIdAsync(sendParams.FromUserId, sendParams.RecipientId);
|
||||
}
|
||||
else if (sendParams.RecipientType == RecipientType.Group)
|
||||
{
|
||||
|
||||
@@ -25,26 +25,24 @@ public class MessagesLoader : IMessagesLoader
|
||||
}
|
||||
|
||||
public async Task<List<Message>> LoadMessagesInUserChat(
|
||||
Guid userId,
|
||||
Guid privateChatId,
|
||||
Guid currentUser,
|
||||
Guid? startMessageId,
|
||||
int before = 20,
|
||||
int after = 2)
|
||||
{
|
||||
if (userId == Guid.Empty)
|
||||
throw new ArgumentException("User id cannot be empty");
|
||||
if (privateChatId == Guid.Empty)
|
||||
throw new ArgumentException("PrivateChatId id cannot be empty");
|
||||
|
||||
if (!_privateChatsRepository.Exist(userId, currentUser))
|
||||
if (!_privateChatsRepository.Exist(privateChatId))
|
||||
throw new InvalidOperationException("Private chat not found");
|
||||
|
||||
var chat = await _privateChatsRepository.GetByMembersAsync(userId, currentUser);
|
||||
|
||||
|
||||
var query = _dbContext.Messages
|
||||
.AsNoTracking()
|
||||
.Include(m => m.MediaAttachments)
|
||||
.ThenInclude(m => m.MediaFile)
|
||||
.Where(m => m.RecipientType == RecipientType.User &&
|
||||
m.RecipientId == chat.Id);
|
||||
m.RecipientId == privateChatId);
|
||||
|
||||
if (startMessageId is null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user