diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs index bc69d682..7d482fb3 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs @@ -27,12 +27,18 @@ public class RemoveHistoryHandler : INotificationHandler /// /// - public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel) + public Task Handle(RemoveSignatureNotification notification, CancellationToken cancel) { - await _repo.DeleteAsync(hists - => hists + return _repo.DeleteAsync(hists => + { + hists = hists .Where(hist => hist.Envelope!.Uuid == notification.EnvelopeUuid) - .Where(hist => hist.Status == EnvelopeStatus.DocumentSigned), - cancel); + .Where(hist => hist.Status == EnvelopeStatus.DocumentSigned); + + if (notification.ReceiverSignature is string signature) + hists = hists.Where(hist => hist.Receiver!.Signature == signature); + + return hists; + }, cancel); } } \ No newline at end of file