Files
documenso/packages/trpc/server/envelope-router/envelope-recipients/update-envelope-recipients.ts
2025-10-28 20:32:24 +11:00

42 lines
1.1 KiB
TypeScript

import { updateEnvelopeRecipients } from '@documenso/lib/server-only/recipient/update-envelope-recipients';
import { authenticatedProcedure } from '../../trpc';
import {
ZUpdateEnvelopeRecipientsRequestSchema,
ZUpdateEnvelopeRecipientsResponseSchema,
} from './update-envelope-recipients.types';
export const updateEnvelopeRecipientsRoute = authenticatedProcedure
.meta({
openapi: {
method: 'POST',
path: '/envelope/recipient/update-many',
summary: 'Update envelope recipients',
description: 'Update multiple recipients for an envelope',
tags: ['Envelope Recipient'],
},
})
.input(ZUpdateEnvelopeRecipientsRequestSchema)
.output(ZUpdateEnvelopeRecipientsResponseSchema)
.mutation(async ({ input, ctx }) => {
const { user, teamId } = ctx;
const { envelopeId, data: recipients } = input;
ctx.logger.info({
input: {
envelopeId,
},
});
return await updateEnvelopeRecipients({
userId: user.id,
teamId,
id: {
type: 'envelopeId',
id: envelopeId,
},
recipients,
requestMetadata: ctx.metadata,
});
});