fix: replyTo includes the correct email (#21843)

* fix: delete dilog button not visible

* fix: replyTo includes the correct email

* Update getReplyToHeader.ts
This commit is contained in:
Anik Dhabal Babu
2025-06-17 10:45:44 +00:00
committed by GitHub
parent 4920abdaf7
commit 1674ecc585
10 changed files with 53 additions and 17 deletions
@@ -19,7 +19,8 @@ export default class OrganizerAddGuestsEmail extends OrganizerScheduledEmail {
to: toAddresses.join(","),
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.t("guests_added_event_type_subject", {
eventType: this.calEvent.type,
@@ -26,7 +26,8 @@ export default class OrganizerDailyVideoDownloadRecordingEmail extends BaseEmail
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.t("download_recording_subject", {
title: this.calEvent.title,
@@ -38,7 +38,8 @@ export default class OrganizerDailyVideoDownloadTranscriptEmail extends BaseEmai
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.t("download_transcript_email_subject", {
title: this.calEvent.title,
@@ -19,7 +19,8 @@ export default class OrganizerLocationChangeEmail extends OrganizerScheduledEmai
to: toAddresses.join(","),
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.t("location_changed_event_type_subject", {
eventType: this.calEvent.type,
@@ -24,7 +24,8 @@ export default class OrganizerRequestEmail extends OrganizerScheduledEmail {
to: toAddresses.join(","),
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.t("awaiting_approval")}: ${this.calEvent.title}`,
html: await this.getHtmlRequestEmail(template, this.calEvent, this.calEvent.organizer),
@@ -13,7 +13,8 @@ export default class OrganizerRequestReminderEmail extends OrganizerRequestEmail
to: toAddresses.join(","),
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.t("event_awaiting_approval_subject", {
title: this.calEvent.title,
@@ -19,7 +19,8 @@ export default class OrganizerRescheduledEmail extends OrganizerScheduledEmail {
to: toAddresses.join(","),
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.calEvent.organizer.language.translate("event_type_has_been_rescheduled_on_time_date", {
title: this.calEvent.title,
@@ -52,7 +52,8 @@ export default class OrganizerScheduledEmail extends BaseEmail {
to: toAddresses.join(","),
...getReplyToHeader(
this.calEvent,
this.calEvent.attendees.map(({ email }) => email)
this.calEvent.attendees.map(({ email }) => email),
true
),
subject: `${this.newSeat ? `${this.t("new_attendee")}: ` : ""}${this.calEvent.title}`,
html: await this.getHtml(
+13 -2
View File
@@ -3,6 +3,17 @@ import type { CalendarEvent } from "@calcom/types/Calendar";
/**
* Returns the reply-to email address to use, with fallback to organizer's email
*/
export const getReplyToEmail = (calEvent: Pick<CalendarEvent, "customReplyToEmail" | "organizer">) => {
return calEvent.customReplyToEmail || calEvent.organizer.email;
export const getReplyToEmail = (
calEvent: Pick<CalendarEvent, "customReplyToEmail" | "organizer">,
excludeOrganizerEmail?: boolean
) => {
if (calEvent.customReplyToEmail) {
return calEvent.customReplyToEmail;
}
if (excludeOrganizerEmail) {
return null;
}
return calEvent.organizer.email;
};
+24 -7
View File
@@ -2,15 +2,32 @@ import type { CalendarEvent } from "@calcom/types/Calendar";
import { getReplyToEmail } from "./getReplyToEmail";
export function getReplyToHeader(calEvent: CalendarEvent, additionalEmails?: string | string[]) {
export function getReplyToHeader(
calEvent: CalendarEvent,
additionalEmails?: string | string[],
excludeOrganizerEmail?: boolean
) {
if (calEvent.hideOrganizerEmail) return {};
const replyToEmail = getReplyToEmail(calEvent);
const replyTo = additionalEmails
? Array.isArray(additionalEmails)
? [...additionalEmails, replyToEmail]
: [additionalEmails, replyToEmail]
: replyToEmail;
const replyToEmail = getReplyToEmail(calEvent, excludeOrganizerEmail);
const emailArray: string[] = [];
if (additionalEmails) {
if (Array.isArray(additionalEmails)) {
emailArray.push(...additionalEmails);
} else {
emailArray.push(additionalEmails);
}
}
if (replyToEmail) {
emailArray.push(replyToEmail);
}
if (emailArray.length === 0) {
return {};
}
const replyTo = emailArray.length === 1 ? emailArray[0] : emailArray;
return { replyTo };
}