2021-06-29 21:43:18 +00:00
|
|
|
import dayjs, { Dayjs } from "dayjs";
|
|
|
|
import localizedFormat from "dayjs/plugin/localizedFormat";
|
2021-09-22 19:52:38 +00:00
|
|
|
import timezone from "dayjs/plugin/timezone";
|
|
|
|
import utc from "dayjs/plugin/utc";
|
|
|
|
|
|
|
|
import EventMail from "./EventMail";
|
2021-07-07 10:43:13 +00:00
|
|
|
|
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-07-16 20:57:44 +00:00
|
|
|
<body style="background: #f4f5f7; font-family: Helvetica, sans-serif">
|
|
|
|
<div
|
|
|
|
style="
|
|
|
|
margin: 0 auto;
|
|
|
|
max-width: 450px;
|
|
|
|
background: white;
|
|
|
|
border-radius: 0.75rem;
|
|
|
|
border: 1px solid #e5e7eb;
|
|
|
|
padding: 2rem 2rem 2rem 2rem;
|
|
|
|
text-align: center;
|
|
|
|
margin-top: 40px;
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
style="height: 60px; width: 60px; color: #31c48d"
|
|
|
|
fill="none"
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
stroke="currentColor"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
stroke-linecap="round"
|
|
|
|
stroke-linejoin="round"
|
|
|
|
stroke-width="2"
|
|
|
|
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
|
|
/>
|
|
|
|
</svg>
|
2021-10-25 13:05:21 +00:00
|
|
|
<h1 style="font-weight: 500; color: #161e2e;">${this.calEvent.language(
|
|
|
|
"your_meeting_has_been_booked"
|
|
|
|
)}</h1>
|
|
|
|
<p style="color: #4b5563; margin-bottom: 30px;">${this.calEvent.language("emailed_you_and_attendees")}</p>
|
2021-07-16 20:57:44 +00:00
|
|
|
<hr />
|
|
|
|
<table style="border-spacing: 20px; color: #161e2e; margin-bottom: 10px;">
|
|
|
|
<colgroup>
|
|
|
|
<col span="1" style="width: 40%;">
|
|
|
|
<col span="1" style="width: 60%;">
|
|
|
|
</colgroup>
|
|
|
|
<tr>
|
2021-10-25 13:05:21 +00:00
|
|
|
<td>${this.calEvent.language("what")}</td>
|
2021-07-16 20:57:44 +00:00
|
|
|
<td>${this.calEvent.type}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2021-10-25 13:05:21 +00:00
|
|
|
<td>${this.calEvent.language("when")}</td>
|
2021-09-21 10:36:29 +00:00
|
|
|
<td>${this.getInviteeStart().format("dddd, LL")}<br>${this.getInviteeStart().format("h:mma")} (${
|
|
|
|
this.calEvent.attendees[0].timeZone
|
2021-07-16 20:57:44 +00:00
|
|
|
})</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2021-10-25 13:05:21 +00:00
|
|
|
<td>${this.calEvent.language("who")}</td>
|
2021-09-06 09:06:33 +00:00
|
|
|
<td>
|
|
|
|
${this.calEvent.team?.name || this.calEvent.organizer.name}<br />
|
|
|
|
<small>
|
|
|
|
${this.calEvent.organizer.email && !this.calEvent.team ? this.calEvent.organizer.email : ""}
|
|
|
|
${this.calEvent.team ? this.calEvent.team.members.join(", ") : ""}
|
|
|
|
</small>
|
|
|
|
</td>
|
2021-07-16 20:57:44 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2021-10-25 13:05:21 +00:00
|
|
|
<td>${this.calEvent.language("where")}</td>
|
2021-07-16 20:57:44 +00:00
|
|
|
<td>${this.getLocation()}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2021-10-25 13:05:21 +00:00
|
|
|
<td>${this.calEvent.language("notes")}</td>
|
2021-07-16 20:57:44 +00:00
|
|
|
<td>${this.calEvent.description}</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
` +
|
2021-06-29 21:43:18 +00:00
|
|
|
this.getAdditionalBody() +
|
2021-06-29 00:30:45 +00:00
|
|
|
"<br />" +
|
2021-07-16 20:57:44 +00:00
|
|
|
`
|
|
|
|
<hr />
|
|
|
|
` +
|
2021-06-29 21:43:18 +00:00
|
|
|
this.getAdditionalFooter() +
|
|
|
|
`
|
2021-07-16 20:57:44 +00:00
|
|
|
</div>
|
|
|
|
<div style="text-align: center; margin-top: 20px; color: #ccc; font-size: 12px;">
|
2021-09-21 09:59:34 +00:00
|
|
|
<img style="opacity: 0.25; width: 120px;" src="https://app.cal.com/cal-logo-word.svg" alt="Cal.com Logo"></div>
|
2021-07-16 20:57:44 +00:00
|
|
|
</body>
|
2021-06-29 21:43:18 +00:00
|
|
|
`
|
|
|
|
);
|
2021-06-16 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
2021-06-29 00:30:45 +00:00
|
|
|
/**
|
|
|
|
* Adds the video call information to the mail body.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
protected getLocation(): string {
|
2021-10-25 13:05:21 +00:00
|
|
|
if (this.calEvent.additionInformation?.hangoutLink) {
|
|
|
|
return `<a href="${this.calEvent.additionInformation?.hangoutLink}">${this.calEvent.additionInformation?.hangoutLink}</a><br />`;
|
2021-06-29 00:30:45 +00:00
|
|
|
}
|
|
|
|
|
2021-10-25 13:05:21 +00:00
|
|
|
if (
|
|
|
|
this.calEvent.additionInformation?.entryPoints &&
|
|
|
|
this.calEvent.additionInformation?.entryPoints.length > 0
|
|
|
|
) {
|
|
|
|
const locations = this.calEvent.additionInformation?.entryPoints
|
2021-06-29 00:30:45 +00:00
|
|
|
.map((entryPoint) => {
|
|
|
|
return `
|
2021-10-25 13:05:21 +00:00
|
|
|
${this.calEvent.language("join_by_entrypoint", { entryPoint: entryPoint.entryPointType })}: <br />
|
2021-06-29 00:30:45 +00:00
|
|
|
<a href="${entryPoint.uri}">${entryPoint.label}</a> <br />
|
|
|
|
`;
|
|
|
|
})
|
|
|
|
.join("<br />");
|
|
|
|
|
2021-07-16 20:57:44 +00:00
|
|
|
return `${locations}`;
|
2021-06-29 00:30:45 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 20:57:44 +00:00
|
|
|
return this.calEvent.location ? `${this.calEvent.location}<br /><br />` : "";
|
2021-06-29 00:30:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected getAdditionalBody(): string {
|
2021-07-16 20:57:44 +00:00
|
|
|
return ``;
|
2021-06-16 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 09:06:33 +00:00
|
|
|
protected getAdditionalFooter(): string {
|
|
|
|
return this.parser.getChangeEventFooterHtml();
|
|
|
|
}
|
|
|
|
|
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-10-25 13:05:21 +00:00
|
|
|
subject: this.calEvent.language("confirmed_event_type_subject", {
|
|
|
|
eventType: this.calEvent.type,
|
|
|
|
name: this.calEvent.team?.name || this.calEvent.organizer.name,
|
|
|
|
date: this.getInviteeStart().format("LT dddd, LL"),
|
|
|
|
}),
|
2021-06-16 22:26:51 +00:00
|
|
|
html: this.getHtmlRepresentation(),
|
|
|
|
text: this.getPlainTextRepresentation(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-10-25 13:05:21 +00:00
|
|
|
protected printNodeMailerError(error: Error): void {
|
2021-06-16 22:26:51 +00:00
|
|
|
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-09-22 19:52:38 +00:00
|
|
|
return dayjs(this.calEvent.startTime).tz(this.calEvent.attendees[0].timeZone);
|
2021-06-16 22:26:51 +00:00
|
|
|
}
|
2021-06-29 21:43:18 +00:00
|
|
|
}
|