preserve customReplyToEmail (#27941)
This commit is contained in:
@@ -352,6 +352,13 @@ async function handler(req: NextRequest) {
|
||||
title: booking.title || booking.eventType?.title || "",
|
||||
};
|
||||
|
||||
const customReplyTo = reminder.booking?.eventType?.customReplyToEmail;
|
||||
const fallbackReplyTo =
|
||||
reminder.booking?.userPrimaryEmail ?? reminder.booking?.user?.email;
|
||||
const replyTo = reminder.booking?.eventType?.hideOrganizerEmail
|
||||
? customReplyTo
|
||||
: customReplyTo ?? fallbackReplyTo;
|
||||
|
||||
const mailData = {
|
||||
subject: emailContent.emailSubject,
|
||||
to: Array.isArray(sendTo) ? sendTo : [sendTo],
|
||||
@@ -367,13 +374,8 @@ async function handler(req: NextRequest) {
|
||||
]
|
||||
: undefined,
|
||||
sender: reminder.workflowStep.sender,
|
||||
...(!reminder.booking?.eventType?.hideOrganizerEmail && {
|
||||
replyTo:
|
||||
reminder.booking?.eventType?.customReplyToEmail ??
|
||||
reminder.booking?.userPrimaryEmail ??
|
||||
reminder.booking.user?.email,
|
||||
}),
|
||||
};
|
||||
...(replyTo ? { replyTo } : {}),
|
||||
};
|
||||
|
||||
if (isSendgridEnabled) {
|
||||
sendEmailPromises.push(
|
||||
@@ -448,18 +450,19 @@ async function handler(req: NextRequest) {
|
||||
});
|
||||
if (emailContent.emailSubject.length > 0 && !emailBodyEmpty && sendTo) {
|
||||
const batchId = isSendgridEnabled ? await getBatchId() : undefined;
|
||||
const customReplyTo = reminder.booking?.eventType?.customReplyToEmail;
|
||||
const fallbackReplyTo =
|
||||
reminder.booking?.userPrimaryEmail || reminder.booking?.user?.email;
|
||||
const replyTo = reminder.booking?.eventType?.hideOrganizerEmail
|
||||
? customReplyTo
|
||||
: customReplyTo || fallbackReplyTo;
|
||||
|
||||
const mailData = {
|
||||
subject: emailContent.emailSubject,
|
||||
to: [sendTo],
|
||||
html: emailContent.emailBody,
|
||||
sender: reminder.workflowStep?.sender,
|
||||
...(!reminder.booking?.eventType?.hideOrganizerEmail && {
|
||||
replyTo:
|
||||
reminder.booking?.eventType?.customReplyToEmail ||
|
||||
reminder.booking?.userPrimaryEmail ||
|
||||
reminder.booking.user?.email,
|
||||
}),
|
||||
...(replyTo ? { replyTo } : {}),
|
||||
};
|
||||
if (isSendgridEnabled) {
|
||||
sendEmailPromises.push(
|
||||
|
||||
@@ -571,12 +571,14 @@ export class EmailWorkflowService {
|
||||
const customReplyToEmail =
|
||||
evt?.eventType?.customReplyToEmail || (evt as CalendarEvent).customReplyToEmail;
|
||||
|
||||
const replyTo = evt.hideOrganizerEmail
|
||||
? customReplyToEmail
|
||||
: customReplyToEmail || evt.organizer.email;
|
||||
|
||||
return {
|
||||
subject: emailContent.emailSubject,
|
||||
html: emailContent.emailBody,
|
||||
...(!evt.hideOrganizerEmail && {
|
||||
replyTo: customReplyToEmail || evt.organizer.email,
|
||||
}),
|
||||
...(replyTo && { replyTo }),
|
||||
attachments,
|
||||
sender,
|
||||
};
|
||||
|
||||
@@ -7,9 +7,7 @@ export function getReplyToHeader(
|
||||
additionalEmails?: string | string[],
|
||||
excludeOrganizerEmail?: boolean
|
||||
) {
|
||||
if (calEvent.hideOrganizerEmail) return {};
|
||||
|
||||
const replyToEmail = getReplyToEmail(calEvent, excludeOrganizerEmail);
|
||||
const replyToEmail = getReplyToEmail(calEvent, excludeOrganizerEmail ?? calEvent.hideOrganizerEmail);
|
||||
const emailArray: string[] = [];
|
||||
|
||||
if (additionalEmails) {
|
||||
|
||||
Reference in New Issue
Block a user