fix(email): 🐛 Reply to name parsing
This commit is contained in:
@@ -67,7 +67,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
resultValues: ResultValues
|
resultValues: ResultValues
|
||||||
fileUrls?: string
|
fileUrls?: string
|
||||||
}
|
}
|
||||||
const replyToName = replyTo?.split(' <')[0].replace(/"/g, '')
|
const { name: replyToName } = parseEmailRecipient(replyTo)
|
||||||
|
|
||||||
const { host, port, isTlsEnabled, username, password, from } =
|
const { host, port, isTlsEnabled, username, password, from } =
|
||||||
(await getEmailInfo(credentialsId)) ?? {}
|
(await getEmailInfo(credentialsId)) ?? {}
|
||||||
@@ -191,4 +191,20 @@ const getEmailBody = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parseEmailRecipient = (
|
||||||
|
recipient?: string
|
||||||
|
): { email?: string; name?: string } => {
|
||||||
|
if (!recipient) return {}
|
||||||
|
if (recipient.includes('<')) {
|
||||||
|
const [name, email] = recipient.split('<')
|
||||||
|
return {
|
||||||
|
name: name.replace(/>/g, '').trim().replace(/"/g, ''),
|
||||||
|
email: email.replace('>', '').trim(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
email: recipient,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default withSentry(handler)
|
export default withSentry(handler)
|
||||||
|
|||||||
Reference in New Issue
Block a user