Skip to content

Commit

Permalink
fix: send emails (#3710)
Browse files Browse the repository at this point in the history
fix: send emails
  • Loading branch information
mariojsnunes committed Jun 28, 2024
1 parent 7856acb commit bb29ad0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions functions/src/emailNotifications/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
}
Expand Down

0 comments on commit bb29ad0

Please sign in to comment.