Skip to content

Commit

Permalink
🐛 (sendEmail) Check if attachment is URL
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 6, 2023
1 parent b455078 commit 7174ef0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from 'models'
import { NextApiRequest, NextApiResponse } from 'next'
import { createTransport, getTestMessageUrl } from 'nodemailer'
import { isEmpty, isNotDefined, omit, parseAnswers } from 'utils'
import { isDefined, isEmpty, isNotDefined, omit, parseAnswers } from 'utils'
import { methodNotAllowed, initMiddleware, decrypt } from 'utils/api'
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'

Expand Down Expand Up @@ -107,7 +107,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
to: recipients,
replyTo,
subject,
attachments: fileUrls?.split(', ').map((url) => ({ path: url })),
attachments: fileUrls
?.split(', ')
.map((url) => (url.startsWith('http') ? { path: url } : undefined))
.filter(isDefined),
...emailBody,
}
try {
Expand Down

0 comments on commit 7174ef0

Please sign in to comment.