Files
calendar/packages/emails/lib/generateIcsFile.ts
T
399a23a52f fix: Disable ICS file generation when destination calendar is Outlook (#16247)
* Set the organizer in the organizer field

* Create generateIcsFile

* Add role enum and only disable for organizers

* Move emails to generateIcsFile

* Add new ics func to new emails

* Fix tests

* Type fix

---------

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
2024-08-22 09:49:53 +00:00

52 lines
1.1 KiB
TypeScript

import type { EventStatus } from "ics";
import type { TFunction } from "next-i18next";
import type { CalendarEvent } from "@calcom/types/Calendar";
import generateIcsString from "./generateIcsString";
export enum GenerateIcsRole {
ATTENDEE = "attendee",
ORGANIZER = "organizer",
}
export default function generateIcsFile({
calEvent,
title,
subtitle,
role,
status,
t,
isRequestReschedule,
}: {
calEvent: CalendarEvent;
title: string;
subtitle: string;
role: GenerateIcsRole;
status: EventStatus;
t?: TFunction;
isRequestReschedule?: boolean;
}) {
// 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,
title,
subtitle,
role,
status,
t,
isRequestReschedule,
}),
method: "REQUEST",
};
}