From 7ed31c441c9dec30e33b6452e6c6839f3ec6adbe Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung Date: Mon, 30 Oct 2023 16:46:56 -0400 Subject: [PATCH] Add status as param --- packages/emails/lib/generateIcsString.ts | 6 ++++-- .../emails/templates/attendee-rescheduled-email.ts | 7 ++++++- packages/emails/templates/attendee-scheduled-email.ts | 7 ++++++- .../emails/templates/organizer-cancelled-email.ts | 11 +++++++++++ .../emails/templates/organizer-rescheduled-email.ts | 7 ++++++- .../emails/templates/organizer-scheduled-email.ts | 7 ++++++- 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/packages/emails/lib/generateIcsString.ts b/packages/emails/lib/generateIcsString.ts index d04143dd81..388926114f 100644 --- a/packages/emails/lib/generateIcsString.ts +++ b/packages/emails/lib/generateIcsString.ts @@ -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; diff --git a/packages/emails/templates/attendee-rescheduled-email.ts b/packages/emails/templates/attendee-rescheduled-email.ts index dca0032eda..27dcf178c2 100644 --- a/packages/emails/templates/attendee-rescheduled-email.ts +++ b/packages/emails/templates/attendee-rescheduled-email.ts @@ -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}>`, diff --git a/packages/emails/templates/attendee-scheduled-email.ts b/packages/emails/templates/attendee-scheduled-email.ts index 92aa734aec..5972c8a82f 100644 --- a/packages/emails/templates/attendee-scheduled-email.ts +++ b/packages/emails/templates/attendee-scheduled-email.ts @@ -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}>`, diff --git a/packages/emails/templates/organizer-cancelled-email.ts b/packages/emails/templates/organizer-cancelled-email.ts index d0e2fb315c..9d522ae52a 100644 --- a/packages/emails/templates/organizer-cancelled-email.ts +++ b/packages/emails/templates/organizer-cancelled-email.ts @@ -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", { diff --git a/packages/emails/templates/organizer-rescheduled-email.ts b/packages/emails/templates/organizer-rescheduled-email.ts index 11c50073f7..d34a409773 100644 --- a/packages/emails/templates/organizer-rescheduled-email.ts +++ b/packages/emails/templates/organizer-rescheduled-email.ts @@ -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(","), diff --git a/packages/emails/templates/organizer-scheduled-email.ts b/packages/emails/templates/organizer-scheduled-email.ts index e8a4b6bf43..9d4e8de954 100644 --- a/packages/emails/templates/organizer-scheduled-email.ts +++ b/packages/emails/templates/organizer-scheduled-email.ts @@ -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}>`,