mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
use nodemailer instead of sendgrid
This commit is contained in:
@@ -63,12 +63,16 @@ export default async function userHandler(
|
||||
const { current, previous } = await patchBooking(uuid, req.body)
|
||||
|
||||
// TODO: this should really go into the schema
|
||||
if (wasRejected(previous, current)) {
|
||||
sendBookingRejected(current)
|
||||
} else if (wasConfirmed(previous, current)) {
|
||||
sendBookingConfirmed(current)
|
||||
} else if (wasCanceled(previous, current)) {
|
||||
sendBookingCanceled(current)
|
||||
try {
|
||||
if (wasRejected(previous, current)) {
|
||||
sendBookingRejected(current)
|
||||
} else if (wasConfirmed(previous, current)) {
|
||||
sendBookingConfirmed(current)
|
||||
} else if (wasCanceled(previous, current)) {
|
||||
sendBookingCanceled(current)
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`Failed to send booking ${current} for booking ${uuid}`)
|
||||
}
|
||||
|
||||
res.status(200).json(current)
|
||||
@@ -81,4 +85,4 @@ export default async function userHandler(
|
||||
res.setHeader('Allow', ['PATCH'])
|
||||
res.status(405).end(`Method ${method} Not Allowed`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,17 +34,29 @@ export default async function userHandler(
|
||||
`received booking ${booking.uuid} from ${booking.email}`,
|
||||
booking
|
||||
)
|
||||
await sendReceivedBookingAdminMail(booking)
|
||||
log.info(`send booking ${booking.uuid} received to admin`, booking)
|
||||
await sendReceivedBookingBookerMail(booking)
|
||||
log.info(
|
||||
`send booking ${booking.uuid} received to {booking.email}`,
|
||||
booking
|
||||
)
|
||||
try {
|
||||
await sendReceivedBookingAdminMail(booking)
|
||||
log.info(`send booking ${booking.uuid} received to admin`, booking)
|
||||
} catch (error) {
|
||||
log.error(`failed to send booking ${booking.uuid} received to admin`, booking)
|
||||
}
|
||||
try {
|
||||
await sendReceivedBookingBookerMail(booking)
|
||||
log.info(
|
||||
`send booking ${booking.uuid} received to {booking.email}`,
|
||||
booking
|
||||
)
|
||||
} catch (error) {
|
||||
log.error(
|
||||
`failed to send booking ${booking.uuid} received to {booking.email}`,
|
||||
booking
|
||||
)
|
||||
|
||||
}
|
||||
res.status(200).json(booking)
|
||||
break
|
||||
default:
|
||||
res.setHeader('Allow', ['POST'])
|
||||
res.status(405).end(`Method ${method} Not Allowed`)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user