Full zoom integration (except availability check)
This commit is contained in:
1 parent
9ff8e9bd00
commit
51a8bafaa7
4 files changed
+56
-18
No files matched your search
@@ -10,21 +10,47 @@ dayjs.extend(localizedFormat);
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
export default function createConfirmBookedEmail(calEvent: CalendarEvent, cancelLink: string, rescheduleLink: string, options: any = {}) {
|
||||
export interface VideoCallData {
|
||||
type: string;
|
||||
id: string;
|
||||
password: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export function integrationTypeToName(type: string): string {
|
||||
//TODO: When there are more complex integration type strings, we should consider using an extra field in the DB for that.
|
||||
const nameProto = type.split("_")[0];
|
||||
return nameProto.charAt(0).toUpperCase() + nameProto.slice(1);
|
||||
}
|
||||
|
||||
export function formattedId(videoCallData: VideoCallData): string {
|
||||
switch(videoCallData.type) {
|
||||
case 'zoom_video':
|
||||
const strId = videoCallData.id.toString();
|
||||
const part1 = strId.slice(0, 3);
|
||||
const part2 = strId.slice(3, 7);
|
||||
const part3 = strId.slice(7, 11);
|
||||
return part1 + " " + part2 + " " + part3;
|
||||
default:
|
||||
return videoCallData.id.toString();
|
||||
}
|
||||
}
|
||||
|
||||
export default function createConfirmBookedEmail(calEvent: CalendarEvent, cancelLink: string, rescheduleLink: string, options: any = {}, videoCallData?: VideoCallData) {
|
||||
return sendEmail(calEvent, cancelLink, rescheduleLink, {
|
||||
provider: {
|
||||
transport: serverConfig.transport,
|
||||
from: serverConfig.from,
|
||||
},
|
||||
...options
|
||||
});
|
||||
}, videoCallData);
|
||||
}
|
||||
|
||||
const sendEmail = (calEvent: CalendarEvent, cancelLink: string, rescheduleLink: string, {
|
||||
provider,
|
||||
}) => new Promise( (resolve, reject) => {
|
||||
}, videoCallData?: VideoCallData) => new Promise((resolve, reject) => {
|
||||
|
||||
const { from, transport } = provider;
|
||||
const {from, transport} = provider;
|
||||
const inviteeStart: Dayjs = <Dayjs>dayjs(calEvent.startTime).tz(calEvent.attendees[0].timeZone);
|
||||
|
||||
nodemailer.createTransport(transport).sendMail(
|
||||
@@ -33,8 +59,8 @@ const sendEmail = (calEvent: CalendarEvent, cancelLink: string, rescheduleLink:
|
||||
from: `${calEvent.organizer.name} <${from}>`,
|
||||
replyTo: calEvent.organizer.email,
|
||||
subject: `Confirmed: ${calEvent.type} with ${calEvent.organizer.name} on ${inviteeStart.format('dddd, LL')}`,
|
||||
html: html(calEvent, cancelLink, rescheduleLink),
|
||||
text: text(calEvent, cancelLink, rescheduleLink),
|
||||
html: html(calEvent, cancelLink, rescheduleLink, videoCallData),
|
||||
text: text(calEvent, cancelLink, rescheduleLink, videoCallData),
|
||||
},
|
||||
(error, info) => {
|
||||
if (error) {
|
||||
@@ -46,7 +72,7 @@ const sendEmail = (calEvent: CalendarEvent, cancelLink: string, rescheduleLink:
|
||||
)
|
||||
});
|
||||
|
||||
const html = (calEvent: CalendarEvent, cancelLink: string, rescheduleLink: string) => {
|
||||
const html = (calEvent: CalendarEvent, cancelLink, rescheduleLink: string, videoCallData?: VideoCallData) => {
|
||||
const inviteeStart: Dayjs = <Dayjs>dayjs(calEvent.startTime).tz(calEvent.attendees[0].timeZone);
|
||||
return `
|
||||
<div>
|
||||
@@ -55,9 +81,14 @@ const html = (calEvent: CalendarEvent, cancelLink: string, rescheduleLink: strin
|
||||
Your ${calEvent.type} with ${calEvent.organizer.name} at ${inviteeStart.format('h:mma')}
|
||||
(${calEvent.attendees[0].timeZone}) on ${inviteeStart.format('dddd, LL')} is scheduled.<br />
|
||||
<br />` + (
|
||||
calEvent.location ? `<strong>Location:</strong> ${calEvent.location}<br /><br />` : ''
|
||||
) +
|
||||
`Additional notes:<br />
|
||||
videoCallData ? `<strong>Video call provider:</strong> ${integrationTypeToName(videoCallData.type)}<br />
|
||||
<strong>Meeting ID:</strong> ${formattedId(videoCallData)}<br />
|
||||
<strong>Meeting Password:</strong> ${videoCallData.password}<br />
|
||||
<strong>Meeting URL:</strong> <a href="${videoCallData.url}">${videoCallData.url}</a><br /><br />` : ''
|
||||
) + (
|
||||
calEvent.location ? `<strong>Location:</strong> ${calEvent.location}<br /><br />` : ''
|
||||
) +
|
||||
`<strong>Additional notes:</strong><br />
|
||||
${calEvent.description}<br />
|
||||
<br />
|
||||
Need to change this event?<br />
|
||||
@@ -67,4 +98,4 @@ const html = (calEvent: CalendarEvent, cancelLink: string, rescheduleLink: strin
|
||||
`;
|
||||
};
|
||||
|
||||
const text = (evt: CalendarEvent, cancelLink: string, rescheduleLink: string) => html(evt, cancelLink, rescheduleLink).replace('<br />', "\n").replace(/<[^>]+>/g, '');
|
||||
const text = (evt: CalendarEvent, cancelLink: string, rescheduleLink: string, videoCallData?: VideoCallData) => html(evt, cancelLink, rescheduleLink, videoCallData).replace('<br />', "\n").replace(/<[^>]+>/g, '');
|
||||
Reference in new issue
Block a user