mirror of
https://github.com/documenso/documenso.git
synced 2026-07-12 22:15:01 +10:00
138d663c25
Merge origin/main into feat/external-2fa-codes. Resolve formatting conflicts caused by biome rollout; preserve both feature streams: PR's external 2FA token + signing-session 2FA proof additions plus main's RateLimit/RecipientExpired/signingReminders/date-auto-insert. In complete-document-with-token.ts, drop the duplicate early field-fetching block introduced when main moved that logic later with date auto-insert support; keep the EXTERNAL_TWO_FACTOR_AUTH check using derivedRecipientActionAuth.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { getEnvelopeById } from '@documenso/lib/server-only/envelope/get-envelope-by-id';
|
|
|
|
import { createAttachment } from '@documenso/lib/server-only/envelope-attachment/create-attachment';
|
|
import { EnvelopeType } from '@prisma/client';
|
|
|
|
import { authenticatedProcedure } from '../../trpc';
|
|
import { ZCreateAttachmentRequestSchema, ZCreateAttachmentResponseSchema } from './create-attachment.types';
|
|
|
|
export const createAttachmentRoute = authenticatedProcedure
|
|
.meta({
|
|
openapi: {
|
|
method: 'POST',
|
|
path: '/document/attachment/create',
|
|
summary: 'Create attachment',
|
|
description: 'Create a new attachment for a document',
|
|
tags: ['Document'],
|
|
},
|
|
})
|
|
.input(ZCreateAttachmentRequestSchema)
|
|
.output(ZCreateAttachmentResponseSchema)
|
|
.mutation(async ({ input, ctx }) => {
|
|
const { teamId } = ctx;
|
|
const userId = ctx.user.id;
|
|
|
|
const { documentId, data } = input;
|
|
|
|
ctx.logger.info({
|
|
input: { documentId, label: data.label },
|
|
});
|
|
|
|
const envelope = await getEnvelopeById({
|
|
id: {
|
|
type: 'documentId',
|
|
id: documentId,
|
|
},
|
|
userId,
|
|
teamId,
|
|
type: EnvelopeType.DOCUMENT,
|
|
});
|
|
|
|
const attachment = await createAttachment({
|
|
envelopeId: envelope.id,
|
|
teamId,
|
|
userId,
|
|
data,
|
|
});
|
|
|
|
return {
|
|
id: attachment.id,
|
|
};
|
|
});
|