Skip to content

Commit c21281a

Browse files
authored
preserve customReplyToEmail (calcom#27941)
1 parent f5a813f commit c21281a

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

packages/features/ee/workflows/api/scheduleEmailReminders.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ async function handler(req: NextRequest) {
352352
title: booking.title || booking.eventType?.title || "",
353353
};
354354

355+
const customReplyTo = reminder.booking?.eventType?.customReplyToEmail;
356+
const fallbackReplyTo =
357+
reminder.booking?.userPrimaryEmail ?? reminder.booking?.user?.email;
358+
const replyTo = reminder.booking?.eventType?.hideOrganizerEmail
359+
? customReplyTo
360+
: customReplyTo ?? fallbackReplyTo;
361+
355362
const mailData = {
356363
subject: emailContent.emailSubject,
357364
to: Array.isArray(sendTo) ? sendTo : [sendTo],
@@ -367,13 +374,8 @@ async function handler(req: NextRequest) {
367374
]
368375
: undefined,
369376
sender: reminder.workflowStep.sender,
370-
...(!reminder.booking?.eventType?.hideOrganizerEmail && {
371-
replyTo:
372-
reminder.booking?.eventType?.customReplyToEmail ??
373-
reminder.booking?.userPrimaryEmail ??
374-
reminder.booking.user?.email,
375-
}),
376-
};
377+
...(replyTo ? { replyTo } : {}),
378+
};
377379

378380
if (isSendgridEnabled) {
379381
sendEmailPromises.push(
@@ -448,18 +450,19 @@ async function handler(req: NextRequest) {
448450
});
449451
if (emailContent.emailSubject.length > 0 && !emailBodyEmpty && sendTo) {
450452
const batchId = isSendgridEnabled ? await getBatchId() : undefined;
453+
const customReplyTo = reminder.booking?.eventType?.customReplyToEmail;
454+
const fallbackReplyTo =
455+
reminder.booking?.userPrimaryEmail || reminder.booking?.user?.email;
456+
const replyTo = reminder.booking?.eventType?.hideOrganizerEmail
457+
? customReplyTo
458+
: customReplyTo || fallbackReplyTo;
451459

452460
const mailData = {
453461
subject: emailContent.emailSubject,
454462
to: [sendTo],
455463
html: emailContent.emailBody,
456464
sender: reminder.workflowStep?.sender,
457-
...(!reminder.booking?.eventType?.hideOrganizerEmail && {
458-
replyTo:
459-
reminder.booking?.eventType?.customReplyToEmail ||
460-
reminder.booking?.userPrimaryEmail ||
461-
reminder.booking.user?.email,
462-
}),
465+
...(replyTo ? { replyTo } : {}),
463466
};
464467
if (isSendgridEnabled) {
465468
sendEmailPromises.push(

packages/features/ee/workflows/lib/service/EmailWorkflowService.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,14 @@ export class EmailWorkflowService {
571571
const customReplyToEmail =
572572
evt?.eventType?.customReplyToEmail || (evt as CalendarEvent).customReplyToEmail;
573573

574+
const replyTo = evt.hideOrganizerEmail
575+
? customReplyToEmail
576+
: customReplyToEmail || evt.organizer.email;
577+
574578
return {
575579
subject: emailContent.emailSubject,
576580
html: emailContent.emailBody,
577-
...(!evt.hideOrganizerEmail && {
578-
replyTo: customReplyToEmail || evt.organizer.email,
579-
}),
581+
...(replyTo && { replyTo }),
580582
attachments,
581583
sender,
582584
};

packages/lib/getReplyToHeader.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ export function getReplyToHeader(
77
additionalEmails?: string | string[],
88
excludeOrganizerEmail?: boolean
99
) {
10-
if (calEvent.hideOrganizerEmail) return {};
11-
12-
const replyToEmail = getReplyToEmail(calEvent, excludeOrganizerEmail);
10+
const replyToEmail = getReplyToEmail(calEvent, excludeOrganizerEmail ?? calEvent.hideOrganizerEmail);
1311
const emailArray: string[] = [];
1412

1513
if (additionalEmails) {

0 commit comments

Comments
 (0)