🐛 (sendEmail) Check if attachment is URL
This commit is contained in:
@ -6,7 +6,7 @@ import {
|
|||||||
} from 'models'
|
} from 'models'
|
||||||
import { NextApiRequest, NextApiResponse } from 'next'
|
import { NextApiRequest, NextApiResponse } from 'next'
|
||||||
import { createTransport, getTestMessageUrl } from 'nodemailer'
|
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 { methodNotAllowed, initMiddleware, decrypt } from 'utils/api'
|
||||||
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'
|
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'
|
||||||
|
|
||||||
@ -107,7 +107,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
to: recipients,
|
to: recipients,
|
||||||
replyTo,
|
replyTo,
|
||||||
subject,
|
subject,
|
||||||
attachments: fileUrls?.split(', ').map((url) => ({ path: url })),
|
attachments: fileUrls
|
||||||
|
?.split(', ')
|
||||||
|
.map((url) => (url.startsWith('http') ? { path: url } : undefined))
|
||||||
|
.filter(isDefined),
|
||||||
...emailBody,
|
...emailBody,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user