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 AttendeeScheduledEmail from "./attendee-scheduled-email"; import { emailHead, emailSchedulingBodyHeader, emailBodyLogo, emailScheduledBodyHeaderContent, emailSchedulingBodyDivider, } from "./common"; dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(localizedFormat); dayjs.extend(toArray); export default class AttendeeRescheduledEmail extends AttendeeScheduledEmail { protected getNodeMailerPayload(): Record { return { icalEvent: { filename: "event.ics", content: this.getiCalEventAsString(), }, to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, replyTo: this.calEvent.organizer.email, subject: `${this.attendee.language.translate("rescheduled_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, })}`, html: this.getHtmlBody(), text: this.getTextBody(), }; } protected getTextBody(): string { // Only the original attendee can make changes to the event // Guests cannot if (this.attendee === this.calEvent.attendees[0]) { return ` ${this.attendee.language.translate("event_has_been_rescheduled")} ${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} ${this.getDescription()} ${this.getAdditionalNotes()} ${this.attendee.language.translate("need_to_reschedule_or_cancel")} ${getCancelLink(this.calEvent)} `.replace(/(<([^>]+)>)/gi, ""); } return ` ${this.attendee.language.translate("event_has_been_rescheduled")} ${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} ${this.getAdditionalNotes()} `.replace(/(<([^>]+)>)/gi, ""); } protected getHtmlBody(): string { const headerContent = this.attendee.language.translate("rescheduled_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" )}, ${this.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); return ` ${emailHead(headerContent)}
${emailSchedulingBodyHeader("calendarCircle")} ${emailScheduledBodyHeaderContent( this.attendee.language.translate("event_has_been_rescheduled"), this.attendee.language.translate("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()}
${this.getWhat()} ${this.getWhen()} ${this.getWho()} ${this.getLocation()} ${this.getDescription()} ${this.getAdditionalNotes()}
${emailSchedulingBodyDivider()}
${this.getManageLink()}
${emailBodyLogo()}
`; } }