Skip to content

Commit

Permalink
VM-1483: delete messages command without replies
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-buravlev committed Oct 30, 2024
1 parent 0771dd6 commit 1b49ba1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.MarketplaceVendorModule.Core" Version="3.825.0-alpha.819" />
<PackageReference Include="VirtoCommerce.CommunicationModule.Core" Version="3.800.0-alpha.8" />
<PackageReference Include="VirtoCommerce.CommunicationModule.Core" Version="3.800.0-alpha.11" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.825.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ public class DeleteMessageCommand : ICommand, IHasSellerId

[Required]
public string[] MessageIds { get; set; }

public bool WithReplies { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
Expand All @@ -9,15 +8,12 @@
namespace VirtoCommerce.MarketplaceCommunicationModule.Data.Commands;
public class DeleteMessageCommandHandler : ICommandHandler<DeleteMessageCommand>
{
private readonly IMessageCrudService _messageCrudService;
private readonly IMessageService _messageService;

public DeleteMessageCommandHandler(
IMessageCrudService messageCrudService,
IMessageService messageService
)
{
_messageCrudService = messageCrudService;
_messageService = messageService;
}

Expand All @@ -33,24 +29,8 @@ public virtual async Task<Unit> Handle(DeleteMessageCommand request, Cancellatio
throw new ArgumentException(nameof(request.MessageIds));
}

var idsToDelete = new List<string>();
if (request.WithReplies)
{
idsToDelete = GetChildMessageIdsRecursively(request.MessageIds);
}
else
{
idsToDelete.AddRange(request.MessageIds);
}

await _messageCrudService.DeleteAsync(idsToDelete);
await _messageService.DeleteMessage(request.MessageIds, false);

return Unit.Value;
}

protected virtual List<string> GetChildMessageIdsRecursively(string[] parendMessageId)
{
return new List<string>(parendMessageId);
//throw new NotImplementedException();
}
}

0 comments on commit 1b49ba1

Please sign in to comment.