import dayjs from "dayjs"; import localizedFormat from "dayjs/plugin/localizedFormat"; import timezone from "dayjs/plugin/timezone"; import toArray from "dayjs/plugin/toArray"; import utc from "dayjs/plugin/utc"; import { getCancelLink } from "@calcom/lib/CalEventParser"; import { emailHead, emailSchedulingBodyHeader, emailBodyLogo, emailScheduledBodyHeaderContent, emailSchedulingBodyDivider, } from "./common"; import OrganizerScheduledEmail from "./organizer-scheduled-email"; dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(localizedFormat); dayjs.extend(toArray); export default class OrganizerRescheduledEmail extends OrganizerScheduledEmail { protected getNodeMailerPayload(): Record { const toAddresses = [this.calEvent.organizer.email]; if (this.calEvent.team) { this.calEvent.team.members.forEach((member) => { const memberAttendee = this.calEvent.attendees.find((attendee) => attendee.name === member); if (memberAttendee) { toAddresses.push(memberAttendee.email); } }); } return { icalEvent: { filename: "event.ics", content: this.getiCalEventAsString(), }, from: `Cal.com <${this.getMailerOptions().from}>`, to: toAddresses.join(","), subject: `${this.calEvent.organizer.language.translate("rescheduled_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.attendees[0].name, date: `${this.getOrganizerStart().format("h:mma")} - ${this.getOrganizerEnd().format( "h:mma" )}, ${this.calEvent.organizer.language.translate( this.getOrganizerStart().format("dddd").toLowerCase() )}, ${this.calEvent.organizer.language.translate( this.getOrganizerStart().format("MMMM").toLowerCase() )} ${this.getOrganizerStart().format("D")}, ${this.getOrganizerStart().format("YYYY")}`, })}`, html: this.getHtmlBody(), text: this.getTextBody(), }; } protected getTextBody(): string { return ` ${this.calEvent.organizer.language.translate("event_has_been_rescheduled")} ${this.calEvent.organizer.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} ${this.getAdditionalNotes()} ${this.calEvent.organizer.language.translate("need_to_reschedule_or_cancel")} ${getCancelLink(this.calEvent)} `.replace(/(<([^>]+)>)/gi, ""); } protected getHtmlBody(): string { const headerContent = this.calEvent.organizer.language.translate("rescheduled_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.attendees[0].name, date: `${this.getOrganizerStart().format("h:mma")} - ${this.getOrganizerEnd().format( "h:mma" )}, ${this.calEvent.organizer.language.translate( this.getOrganizerStart().format("dddd").toLowerCase() )}, ${this.calEvent.organizer.language.translate( this.getOrganizerStart().format("MMMM").toLowerCase() )} ${this.getOrganizerStart().format("D")}, ${this.getOrganizerStart().format("YYYY")}`, }); return ` ${emailHead(headerContent)}
${emailSchedulingBodyHeader("calendarCircle")} ${emailScheduledBodyHeaderContent( this.calEvent.organizer.language.translate("event_has_been_rescheduled"), this.calEvent.organizer.language.translate("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()}
${this.getWhat()} ${this.getWhen()} ${this.getWho()} ${this.getLocation()} ${this.getAdditionalNotes()}
${emailSchedulingBodyDivider()}
${this.getManageLink()}
${emailBodyLogo()}
`; } }