mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +10:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { resendDocument } from '@documenso/lib/server-only/document/resend-document';
|
|
|
|
import { authenticatedProcedure } from '../trpc';
|
|
import {
|
|
ZRedistributeEnvelopeRequestSchema,
|
|
ZRedistributeEnvelopeResponseSchema,
|
|
} from './redistribute-envelope.types';
|
|
|
|
export const redistributeEnvelopeRoute = authenticatedProcedure
|
|
.meta({
|
|
openapi: {
|
|
method: 'POST',
|
|
path: '/envelope/redistribute',
|
|
summary: 'Redistribute envelope',
|
|
description:
|
|
'Redistribute the envelope to the provided recipients who have not actioned the envelope. Will use the distribution method set in the envelope',
|
|
tags: ['Envelope'],
|
|
},
|
|
})
|
|
.input(ZRedistributeEnvelopeRequestSchema)
|
|
.output(ZRedistributeEnvelopeResponseSchema)
|
|
.mutation(async ({ input, ctx }) => {
|
|
const { teamId } = ctx;
|
|
const { envelopeId, recipients } = input;
|
|
|
|
ctx.logger.info({
|
|
input: {
|
|
envelopeId,
|
|
recipients,
|
|
},
|
|
});
|
|
|
|
await resendDocument({
|
|
userId: ctx.user.id,
|
|
teamId,
|
|
id: {
|
|
type: 'envelopeId',
|
|
id: envelopeId,
|
|
},
|
|
recipients,
|
|
requestMetadata: ctx.metadata,
|
|
});
|
|
});
|