mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
Fix webhooks being sent twice due to duplicate frontend calls Updated the assistant confirmation dialog so the next signer is always visible (if dictate is enabled). Because if the form is invalid (due to no name) there is no visual queue that the form is invalid (since it's hidden) ## Notes Didn't bother to remove the weird assistants form since it currently works for now  ## Tests - Currently running locally - Tested webhooks via network tab and via webhook.site
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { upsertDocumentMeta } from '@documenso/lib/server-only/document-meta/upsert-document-meta';
|
|
import { updateDocument } from '@documenso/lib/server-only/document/update-document';
|
|
|
|
import { authenticatedProcedure } from '../trpc';
|
|
import {
|
|
ZUpdateDocumentRequestSchema,
|
|
ZUpdateDocumentResponseSchema,
|
|
} from './update-document.types';
|
|
import { updateDocumentMeta } from './update-document.types';
|
|
|
|
/**
|
|
* Public route.
|
|
*/
|
|
export const updateDocumentRoute = authenticatedProcedure
|
|
.meta(updateDocumentMeta)
|
|
.input(ZUpdateDocumentRequestSchema)
|
|
.output(ZUpdateDocumentResponseSchema)
|
|
.mutation(async ({ input, ctx }) => {
|
|
const { teamId } = ctx;
|
|
const { documentId, data, meta = {} } = input;
|
|
|
|
const userId = ctx.user.id;
|
|
|
|
if (Object.values(meta).length > 0) {
|
|
await upsertDocumentMeta({
|
|
userId: ctx.user.id,
|
|
teamId,
|
|
documentId,
|
|
subject: meta.subject,
|
|
message: meta.message,
|
|
timezone: meta.timezone,
|
|
dateFormat: meta.dateFormat,
|
|
language: meta.language,
|
|
typedSignatureEnabled: meta.typedSignatureEnabled,
|
|
uploadSignatureEnabled: meta.uploadSignatureEnabled,
|
|
drawSignatureEnabled: meta.drawSignatureEnabled,
|
|
redirectUrl: meta.redirectUrl,
|
|
distributionMethod: meta.distributionMethod,
|
|
signingOrder: meta.signingOrder,
|
|
allowDictateNextSigner: meta.allowDictateNextSigner,
|
|
emailSettings: meta.emailSettings,
|
|
requestMetadata: ctx.metadata,
|
|
});
|
|
}
|
|
|
|
return await updateDocument({
|
|
userId,
|
|
teamId,
|
|
documentId,
|
|
data,
|
|
requestMetadata: ctx.metadata,
|
|
});
|
|
});
|