Allow nullable annotation param; validate for non-readonly

Make psPdfKitAnnotation optional in CreateOrUpdate. Add validation to require an annotation for non read-and-confirm envelopes, returning BadRequest if missing.
This commit is contained in:
2026-01-20 12:11:49 +01:00
parent 2795b91386
commit e3d6e87ee5

View File

@@ -44,7 +44,7 @@ public class AnnotationController : ControllerBase
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost]
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation psPdfKitAnnotation, CancellationToken cancel = default)
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation? psPdfKitAnnotation = null, CancellationToken cancel = default)
{
// get claims
var signature = User.GetAuthReceiverSignature();
@@ -56,6 +56,12 @@ public class AnnotationController : ControllerBase
return Unauthorized("User authentication is incomplete. Missing required claims for processing this request.");
}
// check if non read-and-confirm envelope is signed without annotation
var er = await _mediator.ReadEnvelopeReceiverAsync(uuid, signature, cancel).ThrowIfNull(Exceptions.NotFound);
if (!er.Envelope!.ReadOnly && psPdfKitAnnotation is null)
return BadRequest();
// Again check if receiver has already signed
if (await _mediator.IsSignedAsync(uuid, signature, cancel))
return Problem(statusCode: 409);