import dayjs, {Dayjs} from "dayjs"; import EventMail from "./EventMail"; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; import localizedFormat from 'dayjs/plugin/localizedFormat'; dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(localizedFormat); export default class EventAttendeeMail extends EventMail { /** * Returns the email text as HTML representation. * * @protected */ protected getHtmlRepresentation(): string { return `
Hi ${this.calEvent.attendees[0].name},

Your ${this.calEvent.type} with ${this.calEvent.organizer.name} at ${this.getInviteeStart().format('h:mma')} (${this.calEvent.attendees[0].timeZone}) on ${this.getInviteeStart().format('dddd, LL')} is scheduled.

` + this.getAdditionalBody() + ( this.calEvent.location ? `Location: ${this.calEvent.location}

` : '' ) + `Additional notes:
${this.calEvent.description}
` + this.getAdditionalFooter() + `
`; } /** * Returns the payload object for the nodemailer. * * @protected */ protected getNodeMailerPayload(): Object { return { to: `${this.calEvent.attendees[0].name} <${this.calEvent.attendees[0].email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, replyTo: this.calEvent.organizer.email, subject: `Confirmed: ${this.calEvent.type} with ${this.calEvent.organizer.name} on ${this.getInviteeStart().format('dddd, LL')}`, html: this.getHtmlRepresentation(), text: this.getPlainTextRepresentation(), }; } protected printNodeMailerError(error: string): void { console.error("SEND_BOOKING_CONFIRMATION_ERROR", this.calEvent.attendees[0].email, error); } /** * Returns the inviteeStart value used at multiple points. * * @private */ protected getInviteeStart(): Dayjs { return dayjs(this.calEvent.startTime).tz(this.calEvent.attendees[0].timeZone); } }