From 05b7b6741bbe077e3dcce0766ea10f6d1fa7f55c Mon Sep 17 00:00:00 2001 From: Ryderjj89 Date: Mon, 5 May 2025 09:01:16 -0400 Subject: [PATCH] fix: make RSVP email sending optional; skip if EMAIL_USER is not set --- backend/src/index.ts | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 319fc68..ba8bf0a 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -300,22 +300,25 @@ app.post('/api/events/:slug/rsvp', async (req: Request, res: Response) => { const eventTitle = eventInfo ? eventInfo.title : slug; const eventSlug = eventInfo ? eventInfo.slug : slug; - // Send RSVP confirmation email to admin - try { - await sendRSVPEmail({ - eventTitle, - eventSlug, - name, - attending, - bringingGuests: bringing_guests, - guestCount: guest_count, - guestNames: parsedGuestNames, - itemsBringing: parsedItemsBringing, - otherItems: other_items || '', - to: process.env.EMAIL_USER, - }); - } catch (emailErr) { - console.error('Error sending RSVP email:', emailErr); + // Optionally send RSVP confirmation email to admin if EMAIL_USER is set + const adminEmail = process.env.EMAIL_USER; + if (adminEmail) { + try { + await sendRSVPEmail({ + eventTitle, + eventSlug, + name, + attending, + bringingGuests: bringing_guests, + guestCount: guest_count, + guestNames: parsedGuestNames, + itemsBringing: parsedItemsBringing, + otherItems: other_items || '', + to: adminEmail, + }); + } catch (emailErr) { + console.error('Error sending RSVP email:', emailErr); + } } // Return the complete RSVP data including the parsed arrays