Skip to content

Scheduling infrastructure for absolutely everyone.

fix: calendar event description (#1266)

Mihai Cd76ef4a007d7
diff --git a/lib/CalEventParser.ts b/lib/CalEventParser.ts
index ded6fb12b4b..92ba977c92a 100644
--- a/lib/CalEventParser.ts
+++ b/lib/CalEventParser.ts
@@ -1,32 +1,26 @@
-import dayjs from "dayjs";
import short from "short-uuid";
import { v5 as uuidv5 } from "uuid";
import { getIntegrationName } from "@lib/integrations";
-import { CalendarEvent } from "./calendarClient";
+import { CalendarEvent, Person } from "./calendarClient";
import { BASE_URL } from "./config/constants";
const translator = short();
+// The odd indentation in this file is necessary because otherwise the leading tabs will be applied into the event description.
+
export const getWhat = (calEvent: CalendarEvent) => {
return `
-${calEvent.language("what")}
+${calEvent.language("what")}:
${calEvent.type}
`;
};
export const getWhen = (calEvent: CalendarEvent) => {
- const inviteeStart = dayjs(calEvent.startTime).tz(calEvent.attendees[0].timeZone);
- const inviteeEnd = dayjs(calEvent.endTime).tz(calEvent.attendees[0].timeZone);
-
return `
-${calEvent.language("when")}
-${calEvent.language(inviteeStart.format("dddd").toLowerCase())}, ${calEvent.language(
- inviteeStart.format("MMMM").toLowerCase()
- )} ${inviteeStart.format("D")}, ${inviteeStart.format("YYYY")} | ${inviteeStart.format(
- "h:mma"
- )} - ${inviteeEnd.format("h:mma")} (${calEvent.attendees[0].timeZone})
+${calEvent.language("invitee_timezone")}:
+${calEvent.attendees[0].timeZone}
`;
};
@@ -46,14 +40,14 @@ ${calEvent.organizer.email}
`;
return `
-${calEvent.language("who")}
+${calEvent.language("who")}:
${organizer + attendees}
`;
};
export const getAdditionalNotes = (calEvent: CalendarEvent) => {
return `
-${calEvent.language("additional_notes")}
+${calEvent.language("additional_notes")}:
${calEvent.description}
`;
};
@@ -92,13 +86,28 @@ export const getCancelLink = (calEvent: CalendarEvent): string => {
return BASE_URL + "/cancel/" + getUid(calEvent);
};
-export const getRichDescription = (calEvent: CalendarEvent) => {
+export const getRichDescription = (calEvent: CalendarEvent, attendee?: Person) => {
+ // Only the original attendee can make changes to the event
+ // Guests cannot
+
+ if (attendee && attendee === calEvent.attendees[0]) {
+ return `
+${getWhat(calEvent)}
+${getWhen(calEvent)}
+${getWho(calEvent)}
+${calEvent.language("where")}:
+${getLocation(calEvent)}
+${getAdditionalNotes(calEvent)}
+ `.trim();
+ }
+
return `
- ${getWhat(calEvent)}
- ${getWhen(calEvent)}
- ${getWho(calEvent)}
- ${getLocation(calEvent)}
- ${getAdditionalNotes(calEvent)}
- ${getManageLink(calEvent)}
- `;
+${getWhat(calEvent)}
+${getWhen(calEvent)}
+${getWho(calEvent)}
+${calEvent.language("where")}:
+${getLocation(calEvent)}
+${getAdditionalNotes(calEvent)}
+${getManageLink(calEvent)}
+ `.trim();
};
diff --git a/lib/emails/templates/attendee-scheduled-email.ts b/lib/emails/templates/attendee-scheduled-email.ts
index 0e4fea8b6de..7a656291b29 100644
--- a/lib/emails/templates/attendee-scheduled-email.ts
+++ b/lib/emails/templates/attendee-scheduled-email.ts
@@ -6,7 +6,7 @@ import utc from "dayjs/plugin/utc";
import { createEvent, DateArray } from "ics";
import nodemailer from "nodemailer";
-import { getCancelLink } from "@lib/CalEventParser";
+import { getCancelLink, getRichDescription } from "@lib/CalEventParser";
import { CalendarEvent, Person } from "@lib/calendarClient";
import { getErrorFromUnknown } from "@lib/errors";
import { getIntegrationName } from "@lib/integrations";
@@ -113,30 +113,12 @@ export default class AttendeeScheduledEmail {
}
protected getTextBody(): string {
- // Only the original attendee can make changes to the event
- // Guests cannot
- if (this.attendee === this.calEvent.attendees[0]) {
- return `
- ${this.calEvent.language("your_event_has_been_scheduled")}
- ${this.calEvent.language("emailed_you_and_any_other_attendees")}
- ${this.getWhat()}
- ${this.getWhen()}
- ${this.getWho()}
- ${this.getLocation()}
- ${this.getAdditionalNotes()}
- ${this.calEvent.language("need_to_reschedule_or_cancel")}
- ${getCancelLink(this.calEvent)}
- `.replace(/(<([^>]+)>)/gi, "");
- }
-
return `
${this.calEvent.language("your_event_has_been_scheduled")}
${this.calEvent.language("emailed_you_and_any_other_attendees")}
-${this.getWhat()}
-${this.getWhen()}
-${this.getLocation()}
-${this.getAdditionalNotes()}
-`.replace(/(<([^>]+)>)/gi, "");
+
+${getRichDescription(this.calEvent)}
+`.trim();
}
protected printNodeMailerError(error: Error): void {
@@ -364,12 +346,12 @@ ${this.getAdditionalNotes()}
<p style="height: 6px"></p>
<div style="line-height: 6px;">
<p style="color: #494949;">${this.calEvent.language("where")}</p>
- <p style="color: #494949; font-weight: 400; line-height: 24px;">${
- hangoutLink &&
- `<a href="${hangoutLink}" target="_blank" alt="${this.calEvent.language(
- "meeting_url"
- )}"><img src="${linkIcon()}" width="12px"></img></a>`
- }</p>
+ <p style="color: #494949; font-weight: 400; line-height: 24px;">${providerName} ${
+ hangoutLink &&
+ `<a href="${hangoutLink}" target="_blank" alt="${this.calEvent.language(
+ "meeting_url"
+ )}"><img src="${linkIcon()}" width="12px"></img></a>`
+ }</p>
<div style="color: #494949; font-weight: 400; line-height: 24px;"><a href="${hangoutLink}" alt="${this.calEvent.language(
"meeting_url"
)}" style="color: #3E3E3E" target="_blank">${hangoutLink}</a></div>
diff --git a/lib/emails/templates/organizer-scheduled-email.ts b/lib/emails/templates/organizer-scheduled-email.ts
index 3dd206352c5..6b28180917a 100644
--- a/lib/emails/templates/organizer-scheduled-email.ts
+++ b/lib/emails/templates/organizer-scheduled-email.ts
@@ -6,7 +6,7 @@ import utc from "dayjs/plugin/utc";
import { createEvent, DateArray } from "ics";
import nodemailer from "nodemailer";
-import { getCancelLink } from "@lib/CalEventParser";
+import { getCancelLink, getRichDescription } from "@lib/CalEventParser";
import { CalendarEvent, Person } from "@lib/calendarClient";
import { getErrorFromUnknown } from "@lib/errors";
import { getIntegrationName } from "@lib/integrations";
@@ -123,14 +123,9 @@ export default class OrganizerScheduledEmail {
return `
${this.calEvent.language("new_event_scheduled")}
${this.calEvent.language("emailed_you_and_any_other_attendees")}
-${this.getWhat()}
-${this.getWhen()}
-${this.getWho()}
-${this.getLocation()}
-${this.getAdditionalNotes()}
-${this.calEvent.language("need_to_reschedule_or_cancel")}
-${getCancelLink(this.calEvent)}
-`.replace(/(<([^>]+)>)/gi, "");
+
+${getRichDescription(this.calEvent)}
+`.trim();
}
protected printNodeMailerError(error: Error): void {
@@ -352,12 +347,12 @@ ${getCancelLink(this.calEvent)}
<p style="height: 6px"></p>
<div style="line-height: 6px;">
<p style="color: #494949;">${this.calEvent.language("where")}</p>
- <p style="color: #494949; font-weight: 400; line-height: 24px;">${
- hangoutLink &&
- `<a href="${hangoutLink}" target="_blank" alt="${this.calEvent.language(
- "meeting_url"
- )}"><img src="${linkIcon()}" width="12px"></img></a>`
- }</p>
+ <p style="color: #494949; font-weight: 400; line-height: 24px;">${providerName} ${
+ hangoutLink &&
+ `<a href="${hangoutLink}" target="_blank" alt="${this.calEvent.language(
+ "meeting_url"
+ )}"><img src="${linkIcon()}" width="12px"></img></a>`
+ }</p>
<div style="color: #494949; font-weight: 400; line-height: 24px;"><a href="${hangoutLink}" alt="${this.calEvent.language(
"meeting_url"
)}" style="color: #3E3E3E" target="_blank">${hangoutLink}</a></div>