From 52afae331e6dfaf907894aff446d8f732bb04a2c Mon Sep 17 00:00:00 2001 From: Adithya Krishna Date: Wed, 13 Mar 2024 09:50:37 +0530 Subject: [PATCH] chore: updated to send email to doc owners Signed-off-by: Adithya Krishna --- .../server-only/document/send-completed-email.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/lib/server-only/document/send-completed-email.ts b/packages/lib/server-only/document/send-completed-email.ts index 812e54ba3..2ef1da851 100644 --- a/packages/lib/server-only/document/send-completed-email.ts +++ b/packages/lib/server-only/document/send-completed-email.ts @@ -10,6 +10,7 @@ import { DOCUMENT_AUDIT_LOG_TYPE } from '../../types/document-audit-logs'; import type { RequestMetadata } from '../../universal/extract-request-metadata'; import { getFile } from '../../universal/upload/get-file'; import { createDocumentAuditLogData } from '../../utils/document-audit-logs'; +import { getUserById } from '../user/get-user-by-id'; export interface SendDocumentOptions { documentId: number; @@ -40,6 +41,7 @@ export const sendCompletedEmail = async ({ documentId, requestMetadata }: SendDo await Promise.all( document.Recipient.map(async (recipient) => { const { email, name, token } = recipient; + const user = await getUserById({ id: document.userId }); const assetBaseUrl = NEXT_PUBLIC_WEBAPP_URL() || 'http://localhost:3000'; @@ -52,10 +54,16 @@ export const sendCompletedEmail = async ({ documentId, requestMetadata }: SendDo await prisma.$transaction( async (tx) => { await mailer.sendMail({ - to: { - address: email, - name, - }, + to: [ + { + address: email, + name, + }, + { + address: user.email, + name: user.name!, + }, + ], from: { name: process.env.NEXT_PRIVATE_SMTP_FROM_NAME || 'Documenso', address: process.env.NEXT_PRIVATE_SMTP_FROM_ADDRESS || 'noreply@documenso.com',