fix: make RSVP email sending optional; skip if EMAIL_USER is not set

This commit is contained in:
Ryderjj89
2025-05-05 09:01:16 -04:00
parent 246a16f110
commit 05b7b6741b

View File

@@ -300,22 +300,25 @@ app.post('/api/events/:slug/rsvp', async (req: Request, res: Response) => {
const eventTitle = eventInfo ? eventInfo.title : slug; const eventTitle = eventInfo ? eventInfo.title : slug;
const eventSlug = eventInfo ? eventInfo.slug : slug; const eventSlug = eventInfo ? eventInfo.slug : slug;
// Send RSVP confirmation email to admin // Optionally send RSVP confirmation email to admin if EMAIL_USER is set
try { const adminEmail = process.env.EMAIL_USER;
await sendRSVPEmail({ if (adminEmail) {
eventTitle, try {
eventSlug, await sendRSVPEmail({
name, eventTitle,
attending, eventSlug,
bringingGuests: bringing_guests, name,
guestCount: guest_count, attending,
guestNames: parsedGuestNames, bringingGuests: bringing_guests,
itemsBringing: parsedItemsBringing, guestCount: guest_count,
otherItems: other_items || '', guestNames: parsedGuestNames,
to: process.env.EMAIL_USER, itemsBringing: parsedItemsBringing,
}); otherItems: other_items || '',
} catch (emailErr) { to: adminEmail,
console.error('Error sending RSVP email:', emailErr); });
} catch (emailErr) {
console.error('Error sending RSVP email:', emailErr);
}
} }
// Return the complete RSVP data including the parsed arrays // Return the complete RSVP data including the parsed arrays