From bb29ad074e010f90f23b38ee65b100080d1e430e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Nunes?= Date: Sat, 29 Jun 2024 00:40:41 +0700 Subject: [PATCH] fix: send emails (#3710) fix: send emails --- functions/src/emailNotifications/templates/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/src/emailNotifications/templates/index.ts b/functions/src/emailNotifications/templates/index.ts index 4753981a16..8888131053 100644 --- a/functions/src/emailNotifications/templates/index.ts +++ b/functions/src/emailNotifications/templates/index.ts @@ -18,10 +18,12 @@ export type SupportedEmailTemplates = | 'receiver-message' | 'sender-message' -const dirPath = (__dirname || '').replace('/templates', '') - export function getEmailHtml(emailType: SupportedEmailTemplates, ctx: {}) { + let dirPath = path.resolve() + dirPath = dirPath.endsWith('/workspace') ? dirPath : `${dirPath}/dist` // needed to make it work for tests + const availableFiles = fs.readdirSync(path.join(dirPath, '/templates')) + if (!availableFiles.includes(`${emailType}.html`)) { throw new Error(`Email template ${emailType} not found`) }