Files
calendar/packages/emails/lib/generateIcsFile.ts
T
Joe Au-YeungandGitHub 0d757039f7 chore: Fixing ICS file in workflows & ICS calendar descriptions [CAL-4409] (#16731)
* Remove title and subtitle from ICS calendar description

* Remove unused method

* Use generateIcsString function for workflows

* Type fixes

* Refactor typing of CalEventParser

* WIP

* Type fixes

* Fix test

* Fix tests

* type fixes

* Remove duplicate code before `scheduleEmailReminder`
2024-10-07 10:50:50 -04:00

42 lines
910 B
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,
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: "REQUEST",
};
}