mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
4f346d3c2d
Adds a CANCELLED envelope status that privileged members (owner or team admin/manager) can move a pending document into. Sending recipient notifications via a background job while retaining the document in the dashboard as proof of distribution. Includes a dedicated Cancelled tab, single and bulk cancel actions, the ENVELOPE_CANCELLED mutability guard, and e2e coverage for permissions and visibility.
38 lines
916 B
TypeScript
38 lines
916 B
TypeScript
import { cancelDocument } from '@documenso/lib/server-only/document/cancel-document';
|
|
|
|
import { ZGenericSuccessResponse } from '../schema';
|
|
import { authenticatedProcedure } from '../trpc';
|
|
import {
|
|
cancelEnvelopeMeta,
|
|
ZCancelEnvelopeRequestSchema,
|
|
ZCancelEnvelopeResponseSchema,
|
|
} from './cancel-envelope.types';
|
|
|
|
export const cancelEnvelopeRoute = authenticatedProcedure
|
|
.meta(cancelEnvelopeMeta)
|
|
.input(ZCancelEnvelopeRequestSchema)
|
|
.output(ZCancelEnvelopeResponseSchema)
|
|
.mutation(async ({ input, ctx }) => {
|
|
const { teamId } = ctx;
|
|
const { envelopeId, reason } = input;
|
|
|
|
ctx.logger.info({
|
|
input: {
|
|
envelopeId,
|
|
},
|
|
});
|
|
|
|
await cancelDocument({
|
|
id: {
|
|
type: 'envelopeId',
|
|
id: envelopeId,
|
|
},
|
|
userId: ctx.user.id,
|
|
teamId,
|
|
reason,
|
|
requestMetadata: ctx.metadata,
|
|
});
|
|
|
|
return ZGenericSuccessResponse;
|
|
});
|