From a5147acd09934e3e6d341b08bcd1d51566d7ebd5 Mon Sep 17 00:00:00 2001 From: ephraimduncan Date: Wed, 30 Sep 2026 22:10:13 +0000 Subject: [PATCH] fix: correct attachment setting tests and docs The E2E email settings checks now include `attachDocument`. The API docs example sends the full `emailSettings` object, because each omitted setting becomes `true`. The admin view and the settings form use the same label for the attachment setting. The completion email handler keeps the file name code from main. --- .../content/docs/developers/api/documents.mdx | 26 ++++++++++++------- .../general/admin-global-settings-section.tsx | 2 +- .../e2e/api/v2/envelopes-api.spec.ts | 1 + .../organisation-team-preferences.spec.ts | 5 ++++ .../send-document-completed-emails.handler.ts | 4 +-- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/apps/docs/content/docs/developers/api/documents.mdx b/apps/docs/content/docs/developers/api/documents.mdx index 605fd639d..deffad3cb 100644 --- a/apps/docs/content/docs/developers/api/documents.mdx +++ b/apps/docs/content/docs/developers/api/documents.mdx @@ -569,31 +569,39 @@ const document = await response.json(); - ### Omit document PDFs from email -Set `meta.emailSettings.attachDocument` to `false` when creating or updating a document or template. Completion emails still go to the enabled recipients and owner, and retain their document links. This also omits PDFs from CC completion emails. +Set `meta.emailSettings.attachDocument` to `false` when you create or update a document or template. Completion emails still go to the owner and to the enabled recipients, including CC recipients. These emails keep their document links but do not include the PDFs. -| Parameter | Type | Default | Description | -| --------- | ---- | ------- | ----------- | -| `[meta.emailSettings.attachDocument]` | boolean | `true` | Attach completed document PDFs to emails. Set to `false` for links only. | +| Field | Type | Required | Description | +| ----------------------------------- | ------- | -------- | ------------------------------------------------------------- | +| `meta.emailSettings.attachDocument` | boolean | No | Attach completed document PDFs to emails. Defaults to `true`. | -For example, update an envelope with this request body: +The `emailSettings` object replaces all saved email settings. Each setting that you leave out becomes `true`. To change only the attachments, send the complete object with your current values: ```json { "envelopeId": "envelope_abc123", "meta": { "emailSettings": { - "attachDocument": false + "attachDocument": false, + "recipientSigningRequest": true, + "recipientRemoved": true, + "recipientSigned": true, + "documentPending": true, + "documentCompleted": true, + "documentDeleted": true, + "ownerDocumentCompleted": true, + "ownerRecipientExpired": true, + "ownerDocumentCreated": true } } } ``` -When using a template with `/envelope/use`, pass the option in `override.emailSettings`. The document and template APIs, including API v1, accept the same boolean option in their email settings. Non-boolean values are rejected. +When you use a template with `/envelope/use`, set the option in `override.emailSettings`. The document and template APIs, including API v1, accept the same option. The API rejects values that are not booleans. -If you omit the email settings on creation, the document inherits the team's defaults, which can inherit from the organisation. Existing documents and templates retain their saved settings when those defaults change. If you provide an email settings object without `attachDocument`, attachments stay enabled for backward compatibility. +If you omit the email settings on creation, the document inherits the team's defaults, which can inherit from the organisation. Existing documents and templates keep their saved settings when those defaults change. --- diff --git a/apps/remix/app/components/general/admin-global-settings-section.tsx b/apps/remix/app/components/general/admin-global-settings-section.tsx index bd98f4ad3..9defbeda1 100644 --- a/apps/remix/app/components/general/admin-global-settings-section.tsx +++ b/apps/remix/app/components/general/admin-global-settings-section.tsx @@ -10,7 +10,7 @@ import type { ReactNode } from 'react'; import { DetailsCard, DetailsValue } from '~/components/general/admin-details'; const EMAIL_SETTINGS_LABELS: Record = { - attachDocument: msg`Attach completed document PDFs`, + attachDocument: msg`Attach completed document PDFs to emails`, recipientSigningRequest: msg`Recipient signing request`, recipientRemoved: msg`Recipient removed`, recipientSigned: msg`Recipient signed`, diff --git a/packages/app-tests/e2e/api/v2/envelopes-api.spec.ts b/packages/app-tests/e2e/api/v2/envelopes-api.spec.ts index d8ce43169..6fd7762cc 100644 --- a/packages/app-tests/e2e/api/v2/envelopes-api.spec.ts +++ b/packages/app-tests/e2e/api/v2/envelopes-api.spec.ts @@ -198,6 +198,7 @@ test.describe('API V2 Envelopes', () => { drawSignatureEnabled: false, emailReplyTo: userA.email, emailSettings: { + attachDocument: false, recipientSigningRequest: false, recipientRemoved: false, recipientSigned: false, diff --git a/packages/app-tests/e2e/organisations/organisation-team-preferences.spec.ts b/packages/app-tests/e2e/organisations/organisation-team-preferences.spec.ts index 895b0c5aa..932bf4f10 100644 --- a/packages/app-tests/e2e/organisations/organisation-team-preferences.spec.ts +++ b/packages/app-tests/e2e/organisations/organisation-team-preferences.spec.ts @@ -230,6 +230,7 @@ test('[ORGANISATIONS]: manage email preferences', async ({ page }) => { // Check that the team settings have inherited these values. expect(teamSettings.emailReplyTo).toEqual('organisation@documenso.com'); expect(teamSettings.emailDocumentSettings).toEqual({ + attachDocument: true, recipientSigningRequest: true, recipientRemoved: true, recipientSigned: false, // unchecked @@ -273,6 +274,7 @@ test('[ORGANISATIONS]: manage email preferences', async ({ page }) => { // Check that the team settings have overridden the organisation values. expect(updatedTeamSettings.emailReplyTo).toEqual('team@example.com'); expect(updatedTeamSettings.emailDocumentSettings).toEqual({ + attachDocument: true, recipientSigned: true, recipientSigningRequest: false, recipientRemoved: true, @@ -295,6 +297,7 @@ test('[ORGANISATIONS]: manage email preferences', async ({ page }) => { expect(teamOverrideDocumentMeta.emailReplyTo).toEqual('team@example.com'); expect(teamOverrideDocumentMeta.emailSettings).toEqual({ + attachDocument: true, recipientSigned: true, recipientSigningRequest: false, recipientRemoved: true, @@ -322,6 +325,7 @@ test('[ORGANISATIONS]: manage email preferences', async ({ page }) => { // Check that the team settings now inherit from organisation again. expect(inheritedTeamSettings.emailReplyTo).toEqual('organisation@documenso.com'); expect(inheritedTeamSettings.emailDocumentSettings).toEqual({ + attachDocument: true, recipientSigningRequest: true, recipientRemoved: true, recipientSigned: false, @@ -344,6 +348,7 @@ test('[ORGANISATIONS]: manage email preferences', async ({ page }) => { expect(documentMeta.emailReplyTo).toEqual('organisation@documenso.com'); expect(documentMeta.emailSettings).toEqual({ + attachDocument: true, recipientSigningRequest: true, recipientRemoved: true, recipientSigned: false, diff --git a/packages/lib/jobs/definitions/emails/send-document-completed-emails.handler.ts b/packages/lib/jobs/definitions/emails/send-document-completed-emails.handler.ts index 25d69bdc8..5d26750f3 100644 --- a/packages/lib/jobs/definitions/emails/send-document-completed-emails.handler.ts +++ b/packages/lib/jobs/definitions/emails/send-document-completed-emails.handler.ts @@ -101,10 +101,10 @@ export const run = async ({ payload, io }: { payload: TSendDocumentCompletedEmai const file = await getFileServerSide(envelopeItem.documentData); // Use the envelope title for version 1, and the envelope item title for version 2. - const fileNameToUse = envelope.internalVersion === 1 ? envelope.title : `${envelopeItem.title}.pdf`; + const fileNameToUse = envelope.internalVersion === 1 ? envelope.title : envelopeItem.title + '.pdf'; return { - filename: fileNameToUse.endsWith('.pdf') ? fileNameToUse : `${fileNameToUse}.pdf`, + filename: fileNameToUse.endsWith('.pdf') ? fileNameToUse : fileNameToUse + '.pdf', content: Buffer.from(file), contentType: 'application/pdf', };