Files
Gaurav Kumar 188aaa1857 fix(emails): send METHOD:CANCEL in ICS for cancelled bookings (#29708)
Fixes an issue where cancellation emails were sending ICS files with
METHOD:REQUEST instead of METHOD:CANCEL. As per RFC 5546, calendar
clients only process cancellations correctly when METHOD:CANCEL is used,
otherwise cancelled events remain in attendee calendars with active
reminders.

- Use METHOD:CANCEL for cancelled booking ICS files
- Keep METHOD:REQUEST for non-cancelled booking invitations
- Preserve STATUS:CANCELLED and sequence handling
- Add tests to verify the generated ICS method for cancellations
2026-07-05 10:23:53 +00:00

42 lines
941 B
TypeScript

import type { TFunction } from "i18next";
import type { EventStatus } from "ics";
import type { CalendarEvent } from "@calcom/types/Calendar";
import generateIcsString from "./generateIcsString";
export enum GenerateIcsRole {
ATTENDEE = "attendee",
ORGANIZER = "organizer",
}
export default function generateIcsFile({
calEvent,
role,
status,
t,
}: {
calEvent: CalendarEvent;
role: GenerateIcsRole;
status: EventStatus;
t?: TFunction;
}) {
// O365 deletes emails if the calendar event is selected. Currently no option to disable this on the web
if (
role !== GenerateIcsRole.ATTENDEE &&
calEvent.destinationCalendar &&
calEvent.destinationCalendar[0]?.integration === "office365_calendar"
)
return null;
return {
filename: "event.ics",
content: generateIcsString({
event: calEvent,
status,
t,
}),
method: status === "CANCELLED" ? "CANCEL" : "REQUEST",
};
}