feat: add GetDocumentOfSenderAsync to EnvelopeReceiverPageDataService
Loads the PDF bytes for a given envelope on behalf of the authenticated sender (uses SenderId() claim extension). Throws NotFoundException when no document data is available so callers can surface a typed error.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Security.Claims;
|
||||
using System.Text.Json;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.Documents.Queries;
|
||||
@@ -37,6 +38,17 @@ public class EnvelopeReceiverPageDataService(
|
||||
return document.ByteData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the PDF document bytes for the authenticated receiver.
|
||||
/// </summary>
|
||||
public async Task<byte[]?> GetDocumentOfSenderAsync(ClaimsPrincipal user, int envelopeId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var document = await mediator.Send(new ReadDocumentQuery(EnvelopeId: envelopeId, UserId: user.SenderId()), cancellationToken);
|
||||
return (document.ByteData is byte[] data && data.Length > 0)
|
||||
? data
|
||||
: throw new NotFoundException($"Document for envelope {envelopeId} not found.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the current receiver's signature placeholders.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user