Skip to content

Commit 1674ecc

Browse files
authored
fix: replyTo includes the correct email (calcom#21843)
* fix: delete dilog button not visible * fix: replyTo includes the correct email * Update getReplyToHeader.ts
1 parent 4920abd commit 1674ecc

10 files changed

Lines changed: 53 additions & 17 deletions

packages/emails/templates/organizer-add-guests-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export default class OrganizerAddGuestsEmail extends OrganizerScheduledEmail {
1919
to: toAddresses.join(","),
2020
...getReplyToHeader(
2121
this.calEvent,
22-
this.calEvent.attendees.map(({ email }) => email)
22+
this.calEvent.attendees.map(({ email }) => email),
23+
true
2324
),
2425
subject: `${this.t("guests_added_event_type_subject", {
2526
eventType: this.calEvent.type,

packages/emails/templates/organizer-daily-video-download-recording-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default class OrganizerDailyVideoDownloadRecordingEmail extends BaseEmail
2626
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
2727
...getReplyToHeader(
2828
this.calEvent,
29-
this.calEvent.attendees.map(({ email }) => email)
29+
this.calEvent.attendees.map(({ email }) => email),
30+
true
3031
),
3132
subject: `${this.t("download_recording_subject", {
3233
title: this.calEvent.title,

packages/emails/templates/organizer-daily-video-download-transcript-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export default class OrganizerDailyVideoDownloadTranscriptEmail extends BaseEmai
3838
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
3939
...getReplyToHeader(
4040
this.calEvent,
41-
this.calEvent.attendees.map(({ email }) => email)
41+
this.calEvent.attendees.map(({ email }) => email),
42+
true
4243
),
4344
subject: `${this.t("download_transcript_email_subject", {
4445
title: this.calEvent.title,

packages/emails/templates/organizer-location-change-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export default class OrganizerLocationChangeEmail extends OrganizerScheduledEmai
1919
to: toAddresses.join(","),
2020
...getReplyToHeader(
2121
this.calEvent,
22-
this.calEvent.attendees.map(({ email }) => email)
22+
this.calEvent.attendees.map(({ email }) => email),
23+
true
2324
),
2425
subject: `${this.t("location_changed_event_type_subject", {
2526
eventType: this.calEvent.type,

packages/emails/templates/organizer-request-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export default class OrganizerRequestEmail extends OrganizerScheduledEmail {
2424
to: toAddresses.join(","),
2525
...getReplyToHeader(
2626
this.calEvent,
27-
this.calEvent.attendees.map(({ email }) => email)
27+
this.calEvent.attendees.map(({ email }) => email),
28+
true
2829
),
2930
subject: `${this.t("awaiting_approval")}: ${this.calEvent.title}`,
3031
html: await this.getHtmlRequestEmail(template, this.calEvent, this.calEvent.organizer),

packages/emails/templates/organizer-request-reminder-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default class OrganizerRequestReminderEmail extends OrganizerRequestEmail
1313
to: toAddresses.join(","),
1414
...getReplyToHeader(
1515
this.calEvent,
16-
this.calEvent.attendees.map(({ email }) => email)
16+
this.calEvent.attendees.map(({ email }) => email),
17+
true
1718
),
1819
subject: `${this.t("event_awaiting_approval_subject", {
1920
title: this.calEvent.title,

packages/emails/templates/organizer-rescheduled-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export default class OrganizerRescheduledEmail extends OrganizerScheduledEmail {
1919
to: toAddresses.join(","),
2020
...getReplyToHeader(
2121
this.calEvent,
22-
this.calEvent.attendees.map(({ email }) => email)
22+
this.calEvent.attendees.map(({ email }) => email),
23+
true
2324
),
2425
subject: `${this.calEvent.organizer.language.translate("event_type_has_been_rescheduled_on_time_date", {
2526
title: this.calEvent.title,

packages/emails/templates/organizer-scheduled-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export default class OrganizerScheduledEmail extends BaseEmail {
5252
to: toAddresses.join(","),
5353
...getReplyToHeader(
5454
this.calEvent,
55-
this.calEvent.attendees.map(({ email }) => email)
55+
this.calEvent.attendees.map(({ email }) => email),
56+
true
5657
),
5758
subject: `${this.newSeat ? `${this.t("new_attendee")}: ` : ""}${this.calEvent.title}`,
5859
html: await this.getHtml(

packages/lib/getReplyToEmail.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ import type { CalendarEvent } from "@calcom/types/Calendar";
33
/**
44
* Returns the reply-to email address to use, with fallback to organizer's email
55
*/
6-
export const getReplyToEmail = (calEvent: Pick<CalendarEvent, "customReplyToEmail" | "organizer">) => {
7-
return calEvent.customReplyToEmail || calEvent.organizer.email;
6+
export const getReplyToEmail = (
7+
calEvent: Pick<CalendarEvent, "customReplyToEmail" | "organizer">,
8+
excludeOrganizerEmail?: boolean
9+
) => {
10+
if (calEvent.customReplyToEmail) {
11+
return calEvent.customReplyToEmail;
12+
}
13+
14+
if (excludeOrganizerEmail) {
15+
return null;
16+
}
17+
18+
return calEvent.organizer.email;
819
};

packages/lib/getReplyToHeader.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,32 @@ import type { CalendarEvent } from "@calcom/types/Calendar";
22

33
import { getReplyToEmail } from "./getReplyToEmail";
44

5-
export function getReplyToHeader(calEvent: CalendarEvent, additionalEmails?: string | string[]) {
5+
export function getReplyToHeader(
6+
calEvent: CalendarEvent,
7+
additionalEmails?: string | string[],
8+
excludeOrganizerEmail?: boolean
9+
) {
610
if (calEvent.hideOrganizerEmail) return {};
711

8-
const replyToEmail = getReplyToEmail(calEvent);
9-
const replyTo = additionalEmails
10-
? Array.isArray(additionalEmails)
11-
? [...additionalEmails, replyToEmail]
12-
: [additionalEmails, replyToEmail]
13-
: replyToEmail;
12+
const replyToEmail = getReplyToEmail(calEvent, excludeOrganizerEmail);
13+
const emailArray: string[] = [];
1414

15+
if (additionalEmails) {
16+
if (Array.isArray(additionalEmails)) {
17+
emailArray.push(...additionalEmails);
18+
} else {
19+
emailArray.push(additionalEmails);
20+
}
21+
}
22+
23+
if (replyToEmail) {
24+
emailArray.push(replyToEmail);
25+
}
26+
27+
if (emailArray.length === 0) {
28+
return {};
29+
}
30+
31+
const replyTo = emailArray.length === 1 ? emailArray[0] : emailArray;
1532
return { replyTo };
1633
}

0 commit comments

Comments
 (0)