fix: calendar event description (#1266)
parent
c43e6783a7
commit
d76ef4a007
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue