Add status as param

refactor/generate-ics-event
Joe Au-Yeung 2023-10-30 16:46:56 -04:00
parent 397f6eba01
commit 7ed31c441c
6 changed files with 39 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import type { DateArray, ParticipationStatus, ParticipationRole } from "ics";
import type { DateArray, ParticipationStatus, ParticipationRole, EventStatus } from "ics";
import { createEvent } from "ics";
import type { TFunction } from "next-i18next";
import { RRule } from "rrule";
@ -11,10 +11,12 @@ const generateIcsString = ({
event,
t,
role,
status,
}: {
event: CalendarEvent;
t: TFunction;
role: "attendee" | "organizer";
status: EventStatus;
}) => {
// Taking care of recurrence rule
let recurrenceRule: string | undefined = undefined;
@ -79,7 +81,7 @@ ${getRichDescription(event, t)}
: []),
],
method: "REQUEST",
status: "CONFIRMED",
status,
});
if (icsEvent.error) {
throw icsEvent.error;

View File

@ -7,7 +7,12 @@ export default class AttendeeRescheduledEmail extends AttendeeScheduledEmail {
return {
icalEvent: {
filename: "event.ics",
content: generateIcsString({ event: this.calEvent, t: this.t, role: "attendee" }),
content: generateIcsString({
event: this.calEvent,
t: this.t,
role: "attendee",
status: "CONFIRMED",
}),
},
to: `${this.attendee.name} <${this.attendee.email}>`,
from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`,

View File

@ -35,7 +35,12 @@ export default class AttendeeScheduledEmail extends BaseEmail {
return {
icalEvent: {
filename: "event.ics",
content: generateIcsString({ event: this.calEvent, t: this.t, role: "attendee" }),
content: generateIcsString({
event: this.calEvent,
t: this.t,
role: "attendee",
status: "CONFIRMED",
}),
method: "REQUEST",
},
to: `${this.attendee.name} <${this.attendee.email}>`,

View File

@ -1,6 +1,7 @@
import { APP_NAME } from "@calcom/lib/constants";
import { renderEmail } from "../";
import generateIcsString from "../lib/generateIcsString";
import OrganizerScheduledEmail from "./organizer-scheduled-email";
export default class OrganizerCancelledEmail extends OrganizerScheduledEmail {
@ -8,6 +9,16 @@ export default class OrganizerCancelledEmail extends OrganizerScheduledEmail {
const toAddresses = [this.teamMember?.email || this.calEvent.organizer.email];
return {
icalEvent: {
filename: "event.ics",
content: generateIcsString({
event: this.calEvent,
t: this.t,
role: "organizer",
status: "CANCELLED",
}),
method: "request",
},
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
subject: `${this.t("event_cancelled_subject", {

View File

@ -11,7 +11,12 @@ export default class OrganizerRescheduledEmail extends OrganizerScheduledEmail {
return {
icalEvent: {
filename: "event.ics",
content: generateIcsString({ event: this.calEvent, t: this.t, role: "organizer" }),
content: generateIcsString({
event: this.calEvent,
t: this.t,
role: "organizer",
status: "CONFIRMED",
}),
},
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),

View File

@ -33,7 +33,12 @@ export default class OrganizerScheduledEmail extends BaseEmail {
return {
icalEvent: {
filename: "event.ics",
content: generateIcsString({ event: this.calEvent, t: this.t, role: "organizer" }),
content: generateIcsString({
event: this.calEvent,
t: this.t,
role: "organizer",
status: "CONFIRMED",
}),
method: "REQUEST",
},
from: `${APP_NAME} <${this.getMailerOptions().from}>`,