2021-06-29 21:43:18 +00:00
|
|
|
import dayjs, { Dayjs } from "dayjs";
|
2021-06-16 22:26:51 +00:00
|
|
|
import EventMail from "./EventMail";
|
|
|
|
|
2021-06-29 21:43:18 +00:00
|
|
|
import utc from "dayjs/plugin/utc";
|
|
|
|
import timezone from "dayjs/plugin/timezone";
|
|
|
|
import localizedFormat from "dayjs/plugin/localizedFormat";
|
2021-06-21 19:30:00 +00:00
|
|
|
dayjs.extend(utc);
|
|
|
|
dayjs.extend(timezone);
|
|
|
|
dayjs.extend(localizedFormat);
|
|
|
|
|
2021-06-16 22:26:51 +00:00
|
|
|
export default class EventAttendeeMail extends EventMail {
|
|
|
|
/**
|
|
|
|
* Returns the email text as HTML representation.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
protected getHtmlRepresentation(): string {
|
2021-06-29 21:43:18 +00:00
|
|
|
return (
|
|
|
|
`
|
2021-06-16 22:26:51 +00:00
|
|
|
<div>
|
|
|
|
Hi ${this.calEvent.attendees[0].name},<br />
|
|
|
|
<br />
|
2021-06-29 21:43:18 +00:00
|
|
|
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.<br />
|
|
|
|
<br />` +
|
|
|
|
this.getAdditionalBody() +
|
|
|
|
(this.calEvent.location ? `<strong>Location:</strong> ${this.calEvent.location}<br /><br />` : "") +
|
2021-06-16 22:26:51 +00:00
|
|
|
`<strong>Additional notes:</strong><br />
|
2021-06-16 22:57:59 +00:00
|
|
|
${this.calEvent.description}<br />
|
2021-06-29 21:43:18 +00:00
|
|
|
` +
|
|
|
|
this.getAdditionalFooter() +
|
|
|
|
`
|
2021-06-16 22:26:51 +00:00
|
|
|
</div>
|
2021-06-29 21:43:18 +00:00
|
|
|
`
|
|
|
|
);
|
2021-06-16 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the payload object for the nodemailer.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
*/
|
2021-06-29 21:43:18 +00:00
|
|
|
protected getNodeMailerPayload(): Record<string, unknown> {
|
2021-06-16 22:26:51 +00:00
|
|
|
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,
|
2021-06-29 21:43:18 +00:00
|
|
|
subject: `Confirmed: ${this.calEvent.type} with ${
|
|
|
|
this.calEvent.organizer.name
|
|
|
|
} on ${this.getInviteeStart().format("dddd, LL")}`,
|
2021-06-16 22:26:51 +00:00
|
|
|
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
|
|
|
|
*/
|
2021-06-17 00:44:13 +00:00
|
|
|
protected getInviteeStart(): Dayjs {
|
2021-06-16 22:26:51 +00:00
|
|
|
return <Dayjs>dayjs(this.calEvent.startTime).tz(this.calEvent.attendees[0].timeZone);
|
|
|
|
}
|
2021-06-29 21:43:18 +00:00
|
|
|
}
|