fix(emails): customReplyToEmail no longer dropped when hideOrganizerEmail is true (#29940)

* fix: respect customReplyToEmail when hideOrganizerEmail is enabled

* test: get custom reply to in headers
This commit is contained in:
Anirban Singha
2026-08-08 17:13:42 +00:00
committed by GitHub
parent b2c28a23ab
commit 176037d0af
2 changed files with 36 additions and 33 deletions
+18 -5
View File
@@ -8,11 +8,12 @@ import { getReplyToHeader } from "./getReplyToHeader";
* Spec: https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.2
*/
vi.mock("./getReplyToEmail", () => ({
getReplyToEmail: vi.fn((calEvent, excludeOrganizerEmail) => {
if (excludeOrganizerEmail) return null;
return calEvent.organizer?.email || null;
}),
vi.mock("./getReplyToEmail", () => ({
getReplyToEmail: vi.fn((calEvent, excludeOrganizerEmail) => {
if (calEvent.customReplyToEmail) return calEvent.customReplyToEmail;
if (excludeOrganizerEmail) return null;
return calEvent.organizer?.email || null;
}),
}));
const createMockCalEvent = (organizerEmail: string) => ({
@@ -89,4 +90,16 @@ describe("getReplyToHeader", () => {
expect(result.replyTo).not.toContain("]");
});
});
describe("with hideOrganizerEmail and customReplyToEmail", () => {
it("uses customReplyToEmail even when hideOrganizerEmail is true", () => {
const calEvent = {
organizer: { email: "org@test.com" },
hideOrganizerEmail: true,
customReplyToEmail: "custom@test.com",
};
const result = getReplyToHeader(calEvent as any, undefined, true);
expect(result).toEqual({ replyTo: "custom@test.com" });
});
});
});
+18 -28
View File
@@ -2,32 +2,22 @@ import type { CalendarEvent } from "@calcom/types/Calendar";
import { getReplyToEmail } from "./getReplyToEmail";
export function getReplyToHeader(
calEvent: CalendarEvent,
additionalEmails?: string | string[],
excludeOrganizerEmail?: boolean
) {
if (calEvent.hideOrganizerEmail) return {};
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.join(", ");
return { replyTo };
export function getReplyToHeader(
calEvent: CalendarEvent,
additionalEmails?: string | string[],
excludeOrganizerEmail?: boolean
) {
const shouldExcludeOrganizer = excludeOrganizerEmail || calEvent.hideOrganizerEmail;
const replyToEmail = getReplyToEmail(calEvent, shouldExcludeOrganizer);
const emailArray: string[] = [];
if (additionalEmails) {
Array.isArray(additionalEmails) ? emailArray.push(...additionalEmails) : emailArray.push(additionalEmails);
}
if (replyToEmail) {
emailArray.push(replyToEmail);
}
if (emailArray.length === 0) return {};
return { replyTo: emailArray.join(", ") };
}