public async Task GetChatMessages() { var chat = fillTestDbHelper.Chats.FirstOrDefault(); var expectedMessages = fillTestDbHelper.Messages .OrderByDescending(message => message.SendingTime) .Where(message => message.ChatId == chat.Id) .ToList(); var actualMessages = await loadMessagesService.GetMessagesAsync(chat.Id, ConversationType.Chat, true, null, null, 100); Assert.Equal(expectedMessages.FirstOrDefault().GlobalId, actualMessages.FirstOrDefault().GlobalId); }
public async Task HandleAsync() { try { List <long> nodesIds = await conversationsService.GetConversationNodesIdsAsync(request.ConversationType, request.ConversationId).ConfigureAwait(false); if (!nodesIds.Contains(current.Node.Id)) { NodeWebSocketCommunicationManager.SendResponse(new ResultNodeResponse(request.RequestId, ErrorCode.PermissionDenied, "No rights to load messages."), current); return; } List <MessageDto> messages = await loadMessagesService.GetMessagesAsync( request.ConversationId, request.ConversationType, request.Direction.GetValueOrDefault(true), request.MessageId, request.AttachmentsTypes, request.Length).ConfigureAwait(false); MessagesNodeResponse response = new MessagesNodeResponse(request.RequestId, messages); NodeWebSocketCommunicationManager.SendResponse(response, current); } catch (Exception ex) { Logger.WriteLog(ex); NodeWebSocketCommunicationManager.SendResponse(new ResultNodeResponse(request.RequestId, ErrorCode.UnknownError), current); } }