diff --git a/EnvelopeGenerator.Application/DocReceiverElements/Behaviors/AnnotationBehavior.cs b/EnvelopeGenerator.Application/DocReceiverElements/Behaviors/AnnotationBehavior.cs index 1f369f16..4d59ef4e 100644 --- a/EnvelopeGenerator.Application/DocReceiverElements/Behaviors/AnnotationBehavior.cs +++ b/EnvelopeGenerator.Application/DocReceiverElements/Behaviors/AnnotationBehavior.cs @@ -1,4 +1,5 @@ using DigitalData.Core.Abstraction.Application.Repository; +using DigitalData.Core.Exceptions; using EnvelopeGenerator.Application.Common.Dto; using EnvelopeGenerator.Application.DocReceiverElements.Commands; using EnvelopeGenerator.Domain.Entities; @@ -10,13 +11,13 @@ namespace EnvelopeGenerator.Application.DocReceiverElements.Behaviors; /// Pipeline behavior that saves annotations. /// Executes first in the signing process. /// -[Obsolete("This notification is deprecated. Use Signature.Commands.SignCommand instead.")] +[Obsolete("The PSPDFKit library is deprecated.")] public class AnnotationBehavior : IPipelineBehavior { private readonly IRepository _repo; /// - /// + /// Initializes a new instance of the class. /// /// public AnnotationBehavior(IRepository repository) @@ -29,13 +30,21 @@ public class AnnotationBehavior : IPipelineBehavior /// /// /// - /// + /// /// - public async Task Handle(SigningCommand request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task Handle(SigningCommand request, RequestHandlerDelegate next, CancellationToken cancel) { - if (request.PsPdfKitAnnotation is PsPdfKitAnnotation annot) - await _repo.CreateAsync(annot.Structured, cancellationToken); + if(request.ReceiverAppType != ReceiverAppType.LegacyWeb) + if(request.PsPdfKitAnnotation is null) + return await next(cancel); + else + throw new BadRequestException("PsPdfKit Annotation are only supported for the legacy web receiver type."); - return await next(cancellationToken); + if (request.PsPdfKitAnnotation is PsPdfKitAnnotation annot) + await _repo.CreateAsync(annot.Structured, cancel); + else + throw new BadRequestException("Annotation data is missing or invalid."); + + return await next(cancel); } }