Skip to content

Commit

Permalink
fix(mailer): crash if no email recipients were defined
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Jun 10, 2023
1 parent f10da2a commit 6184e68
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/emitter/events/event_ticket_created.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ const parseMemberEmails = async ticket => {
}

const sendMail = async (ticket, emails, baseUrl, betaEnabled) => {
if (emails.length < 1) {
logger.warn('[CreateTicketEvent::SendMail] - No recipients defined for sendMail')
return
}

let email = null

if (betaEnabled) {
Expand Down Expand Up @@ -135,7 +140,10 @@ const sendMail = async (ticket, emails, baseUrl, betaEnabled) => {
}

Mailer.sendMail(mailOptions, function (err) {
if (err) throw err
if (err) {
logger.error(err)
throw err
}

logger.debug(`Sent [${emails.length}] emails.`)
})
Expand Down

0 comments on commit 6184e68

Please sign in to comment.