From 2603ae8b905288c60f2f3abb299e6a320b639a43 Mon Sep 17 00:00:00 2001 From: samuel-cglg <124675162+samuel-cglg@users.noreply.github.com> Date: Sun, 31 Aug 2025 03:37:49 +0200 Subject: [PATCH 1/2] fix: send signing request email after the document status is updated (#1944) When sending a document for signing, emails for recipients are sent before the document status is updated. In this case, the job "send.signing.requested.email" fails because it cannot find the document with a PENDING status. --- .../server-only/document/send-document.tsx | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/lib/server-only/document/send-document.tsx b/packages/lib/server-only/document/send-document.tsx index b8a77ee7e..22dbcb071 100644 --- a/packages/lib/server-only/document/send-document.tsx +++ b/packages/lib/server-only/document/send-document.tsx @@ -148,33 +148,6 @@ export const sendDocument = async ({ // throw new Error('Some signers have not been assigned a signature field.'); // } - const isRecipientSigningRequestEmailEnabled = extractDerivedDocumentEmailSettings( - document.documentMeta, - ).recipientSigningRequest; - - // Only send email if one of the following is true: - // - It is explicitly set - // - The email is enabled for signing requests AND sendEmail is undefined - if (sendEmail || (isRecipientSigningRequestEmailEnabled && sendEmail === undefined)) { - await Promise.all( - recipientsToNotify.map(async (recipient) => { - if (recipient.sendStatus === SendStatus.SENT || recipient.role === RecipientRole.CC) { - return; - } - - await jobs.triggerJob({ - name: 'send.signing.requested.email', - payload: { - userId, - documentId, - recipientId: recipient.id, - requestMetadata: requestMetadata?.requestMetadata, - }, - }); - }), - ); - } - const allRecipientsHaveNoActionToTake = document.recipients.every( (recipient) => recipient.role === RecipientRole.CC || recipient.signingStatus === SigningStatus.SIGNED, @@ -227,6 +200,33 @@ export const sendDocument = async ({ }); }); + const isRecipientSigningRequestEmailEnabled = extractDerivedDocumentEmailSettings( + document.documentMeta, + ).recipientSigningRequest; + + // Only send email if one of the following is true: + // - It is explicitly set + // - The email is enabled for signing requests AND sendEmail is undefined + if (sendEmail || (isRecipientSigningRequestEmailEnabled && sendEmail === undefined)) { + await Promise.all( + recipientsToNotify.map(async (recipient) => { + if (recipient.sendStatus === SendStatus.SENT || recipient.role === RecipientRole.CC) { + return; + } + + await jobs.triggerJob({ + name: 'send.signing.requested.email', + payload: { + userId, + documentId, + recipientId: recipient.id, + requestMetadata: requestMetadata?.requestMetadata, + }, + }); + }), + ); + } + await triggerWebhook({ event: WebhookTriggerEvents.DOCUMENT_SENT, data: ZWebhookDocumentSchema.parse(mapDocumentToWebhookDocumentPayload(updatedDocument)), From 19565c182160ec098a832bb033ced01e006a2723 Mon Sep 17 00:00:00 2001 From: Ephraim Duncan <55143799+ephraimduncan@users.noreply.github.com> Date: Sun, 31 Aug 2025 02:17:31 +0000 Subject: [PATCH 2/2] fix: access audit logs for documents in folder (#1989) --- .../_authenticated+/t.$teamUrl+/documents.$id.logs.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx b/apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx index 56a01bb90..b27ded2bb 100644 --- a/apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx +++ b/apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx @@ -50,10 +50,6 @@ export async function loader({ params, request }: Route.LoaderArgs) { throw redirect(documentRootPath); } - if (document.folderId) { - throw redirect(documentRootPath); - } - const recipients = await getRecipientsForDocument({ documentId, userId: user.id, @@ -68,13 +64,13 @@ export async function loader({ params, request }: Route.LoaderArgs) { return { document, - documentRootPath, recipients, + documentRootPath, }; } export default function DocumentsLogsPage({ loaderData }: Route.ComponentProps) { - const { document, documentRootPath, recipients } = loaderData; + const { document, recipients, documentRootPath } = loaderData; const { _, i18n } = useLingui();