From afa3b54136b83362b5b4062454edbde8c74fa662 Mon Sep 17 00:00:00 2001 From: Vladimir Buravlev Date: Thu, 21 Nov 2024 15:51:28 +0100 Subject: [PATCH] VM-1501: conversation improvements 2 --- .../Repositories/CommunicationRepository.cs | 4 ++-- .../Services/MessageSearchService.cs | 5 +---- .../Functional/MessageSearchServiceTests.cs | 12 +++--------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/VirtoCommerce.CommunicationModule.Data/Repositories/CommunicationRepository.cs b/src/VirtoCommerce.CommunicationModule.Data/Repositories/CommunicationRepository.cs index 8a080b4..c695500 100644 --- a/src/VirtoCommerce.CommunicationModule.Data/Repositories/CommunicationRepository.cs +++ b/src/VirtoCommerce.CommunicationModule.Data/Repositories/CommunicationRepository.cs @@ -136,12 +136,12 @@ public virtual async Task GetCommunicationUserByUserIdA public virtual async Task> GetConversationsByIdsAsync(IList ids, string responseGroup = null) { var result = Array.Empty(); + var respGroupEnum = EnumUtility.SafeParseFlags(responseGroup, ConversationResponseGroup.None); if (!ids.IsNullOrEmpty()) { - result = await Conversations.Where(x => ids.Contains(x.Id)).ToArrayAsync(); + result = await Conversations.Where(x => ids.Contains(x.Id)).Include(x => x.Users).ToArrayAsync(); } - return result; } diff --git a/src/VirtoCommerce.CommunicationModule.Data/Services/MessageSearchService.cs b/src/VirtoCommerce.CommunicationModule.Data/Services/MessageSearchService.cs index a6b55d9..5d72cd2 100644 --- a/src/VirtoCommerce.CommunicationModule.Data/Services/MessageSearchService.cs +++ b/src/VirtoCommerce.CommunicationModule.Data/Services/MessageSearchService.cs @@ -30,10 +30,7 @@ protected override IQueryable BuildQuery(IRepository repository, { var query = ((ICommunicationRepository)repository).Messages; - if (!string.IsNullOrEmpty(criteria.ConversationId)) - { - query = query.Where(x => x.ConversationId == criteria.ConversationId); - } + query = query.Where(x => x.ConversationId == criteria.ConversationId); if (!string.IsNullOrEmpty(criteria.ThreadId)) { diff --git a/tests/VirtoCommerce.CommunicationModule.Tests/Functional/MessageSearchServiceTests.cs b/tests/VirtoCommerce.CommunicationModule.Tests/Functional/MessageSearchServiceTests.cs index fe368a7..434497d 100644 --- a/tests/VirtoCommerce.CommunicationModule.Tests/Functional/MessageSearchServiceTests.cs +++ b/tests/VirtoCommerce.CommunicationModule.Tests/Functional/MessageSearchServiceTests.cs @@ -110,22 +110,16 @@ public static TheoryData MessageSearchTestInput() 1 }, { - null, - null, - false, - 3 - }, - { - null, + "TestConversationId_1", "TestMessageId_1", false, 1 }, { - null, + "TestConversationId_1", null, true, - 2 + 1 } }; }