mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
This PR is handles the changes required to support envelopes. The new envelope editor/signing page will be hidden during release. The core changes here is to migrate the documents and templates model to a centralized envelopes model. Even though Documents and Templates are removed, from the user perspective they will still exist as we remap envelopes to documents and templates.
29 lines
861 B
TypeScript
29 lines
861 B
TypeScript
import { createOrGetShareLink } from '@documenso/lib/server-only/share/create-or-get-share-link';
|
|
|
|
import { procedure } from '../trpc';
|
|
import { ZShareDocumentRequestSchema, ZShareDocumentResponseSchema } from './share-document.types';
|
|
|
|
// Note: This is an unauthenticated route.
|
|
export const shareDocumentRoute = procedure
|
|
.input(ZShareDocumentRequestSchema)
|
|
.output(ZShareDocumentResponseSchema)
|
|
.mutation(async ({ input, ctx }) => {
|
|
const { documentId, token } = input;
|
|
|
|
ctx.logger.info({
|
|
input: {
|
|
documentId,
|
|
},
|
|
});
|
|
|
|
if (token) {
|
|
return await createOrGetShareLink({ documentId, token });
|
|
}
|
|
|
|
if (!ctx.user?.id) {
|
|
throw new Error('You must either provide a token or be logged in to create a sharing link.');
|
|
}
|
|
|
|
return await createOrGetShareLink({ documentId, userId: ctx.user.id });
|
|
});
|