Only send single mail when booking zoom

This commit is contained in:
nicolas committed 2021-07-20 20:07:59 +02:00
1 parent a40a5c04fe
commit 7aff32fb50
3 files changed
+79 -43

No files matched your search

+37 -10
View File
@@ -33,11 +33,13 @@ export default class EventManager {
}
public async create(event: CalendarEvent): Promise<Array<EventResult>> {
// First, create all calendar events.
const results: Array<EventResult> = await this.createAllCalendarEvents(event);
const isVideo = EventManager.isIntegration(event.location);
// First, create all calendar events. If this is a video event, don't send a mail right here.
const results: Array<EventResult> = await this.createAllCalendarEvents(event, isVideo);
// If and only if event type is a video meeting, create a video meeting as well.
if (EventManager.isIntegration(event.location)) {
if (isVideo) {
results.push(await this.createVideoEvent(event));
}
@@ -45,11 +47,13 @@ export default class EventManager {
}
public async update(event: CalendarEvent, booking: PartialBooking): Promise<Array<EventResult>> {
// First, update all calendar events.
const results: Array<EventResult> = await this.updateAllCalendarEvents(event, booking);
const isVideo = EventManager.isIntegration(event.location);
// First, update all calendar events. If this is a video event, don't send a mail right here.
const results: Array<EventResult> = await this.updateAllCalendarEvents(event, booking, isVideo);
// If and only if event type is a video meeting, update the video meeting as well.
if (EventManager.isIntegration(event.location)) {
if (isVideo) {
results.push(await this.updateVideoEvent(event, booking));
}
@@ -58,13 +62,17 @@ export default class EventManager {
/**
* Creates event entries for all calendar integrations given in the credentials.
* When noMail is true, no mails will be sent. This is used when the event is
* a video meeting because then the mail containing the video credentials will be
* more important than the mails created for these bare calendar events.
*
* @param event
* @param noMail
* @private
*/
private createAllCalendarEvents(event: CalendarEvent): Promise<Array<EventResult>> {
private createAllCalendarEvents(event: CalendarEvent, noMail: boolean): Promise<Array<EventResult>> {
return async.mapLimit(this.calendarCredentials, 5, async (credential: Credential) => {
return createEvent(credential, event);
return createEvent(credential, event, noMail);
});
}
@@ -89,16 +97,35 @@ export default class EventManager {
}
}
/**
* Updates the event entries for all calendar integrations given in the credentials.
* When noMail is true, no mails will be sent. This is used when the event is
* a video meeting because then the mail containing the video credentials will be
* more important than the mails created for these bare calendar events.
*
* @param event
* @param booking
* @param noMail
* @private
*/
private updateAllCalendarEvents(
event: CalendarEvent,
booking: PartialBooking
booking: PartialBooking,
noMail: boolean
): Promise<Array<EventResult>> {
return async.mapLimit(this.calendarCredentials, 5, async (credential) => {
const bookingRefUid = booking.references.filter((ref) => ref.type === credential.type)[0]?.uid;
return updateEvent(credential, bookingRefUid, event);
return updateEvent(credential, bookingRefUid, event, noMail);
});
}
/**
* Updates a single video event.
*
* @param event
* @param booking
* @private
*/
private updateVideoEvent(event: CalendarEvent, booking: PartialBooking) {
const credential = this.getVideoCredential(event);