fix: email attachment names (#2085)

This commit is contained in:
David Nguyen
2025-10-21 12:59:40 +11:00
committed by GitHub
parent 1ffc4bd703
commit daab8461c7

View File

@ -81,11 +81,15 @@ export const sendCompletedEmail = async ({ id, requestMetadata }: SendDocumentOp
const { user: owner } = envelope;
const completedDocumentEmailAttachments = await Promise.all(
envelope.envelopeItems.map(async (document) => {
const file = await getFileServerSide(document.documentData);
envelope.envelopeItems.map(async (envelopeItem) => {
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';
return {
fileName: document.title.endsWith('.pdf') ? document.title : document.title + '.pdf',
filename: fileNameToUse.endsWith('.pdf') ? fileNameToUse : fileNameToUse + '.pdf',
content: Buffer.from(file),
contentType: 'application/pdf',
};