feat: support EMAIL_RECIPIENTS for RSVP notifications; send to all listed, fallback to EMAIL_USER, log if none set
This commit is contained in:
@@ -300,10 +300,16 @@ app.post('/api/events/:slug/rsvp', async (req: Request, res: Response) => {
|
||||
const eventTitle = eventInfo ? eventInfo.title : slug;
|
||||
const eventSlug = eventInfo ? eventInfo.slug : slug;
|
||||
|
||||
// Optionally send RSVP confirmation email to admin if EMAIL_USER is set
|
||||
const adminEmail = process.env.EMAIL_USER;
|
||||
if (adminEmail) {
|
||||
// Optionally send RSVP confirmation email to recipients
|
||||
let recipients: string[] = [];
|
||||
if (process.env.EMAIL_RECIPIENTS) {
|
||||
recipients = process.env.EMAIL_RECIPIENTS.split(',').map(addr => addr.trim()).filter(Boolean);
|
||||
} else if (process.env.EMAIL_USER) {
|
||||
recipients = [process.env.EMAIL_USER];
|
||||
}
|
||||
if (recipients.length > 0) {
|
||||
try {
|
||||
for (const to of recipients) {
|
||||
await sendRSVPEmail({
|
||||
eventTitle,
|
||||
eventSlug,
|
||||
@@ -314,11 +320,14 @@ app.post('/api/events/:slug/rsvp', async (req: Request, res: Response) => {
|
||||
guestNames: parsedGuestNames,
|
||||
itemsBringing: parsedItemsBringing,
|
||||
otherItems: other_items || '',
|
||||
to: adminEmail,
|
||||
to,
|
||||
});
|
||||
}
|
||||
} catch (emailErr) {
|
||||
console.error('Error sending RSVP email:', emailErr);
|
||||
}
|
||||
} else {
|
||||
console.warn('No email recipients set. Skipping RSVP email notification.');
|
||||
}
|
||||
|
||||
// Return the complete RSVP data including the parsed arrays
|
||||
|
||||
@@ -17,6 +17,7 @@ services:
|
||||
- EMAIL_FROM_ADDRESS=your@email.com
|
||||
- EMAIL_SECURE=false
|
||||
- FRONTEND_BASE_URL=https://your-frontend-domain.com
|
||||
- EMAIL_RECIPIENTS=admin1@email.com,admin2@email.com
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user