diff --git a/lib/calendarClient.ts b/lib/calendarClient.ts index ff262819f2..1629beee1e 100644 --- a/lib/calendarClient.ts +++ b/lib/calendarClient.ts @@ -439,10 +439,18 @@ const createEvent = async (credential, calEvent: CalendarEvent): Promise => const organizerMail = new EventOrganizerMail(calEvent, uid); const attendeeMail = new EventAttendeeMail(calEvent, uid); - await organizerMail.sendEmail(); + try { + await organizerMail.sendEmail(); + } catch (e) { + console.error("organizerMail.sendEmail failed", e) + } if (!creationResult || !creationResult.disableConfirmationEmail) { - await attendeeMail.sendEmail(); + try { + await attendeeMail.sendEmail(); + } catch (e) { + console.error("attendeeMail.sendEmail failed", e) + } } return { @@ -458,10 +466,18 @@ const updateEvent = async (credential, uidToUpdate: String, calEvent: CalendarEv const organizerMail = new EventOrganizerRescheduledMail(calEvent, newUid); const attendeeMail = new EventAttendeeRescheduledMail(calEvent, newUid); - await organizerMail.sendEmail(); + try { + await organizerMail.sendEmail(); + } catch (e) { + console.error("organizerMail.sendEmail failed", e) + } if (!updateResult || !updateResult.disableConfirmationEmail) { - await attendeeMail.sendEmail(); + try { + await attendeeMail.sendEmail(); + } catch (e) { + console.error("attendeeMail.sendEmail failed", e) + } } return { diff --git a/lib/videoClient.ts b/lib/videoClient.ts index b359e83a96..0e171ac67a 100644 --- a/lib/videoClient.ts +++ b/lib/videoClient.ts @@ -193,10 +193,18 @@ const createMeeting = async (credential, calEvent: CalendarEvent): Promise const organizerMail = new VideoEventOrganizerMail(calEvent, uid, videoCallData); const attendeeMail = new VideoEventAttendeeMail(calEvent, uid, videoCallData); - await organizerMail.sendEmail(); + try { + await organizerMail.sendEmail(); + } catch (e) { + console.error("organizerMail.sendEmail failed", e) + } if (!creationResult || !creationResult.disableConfirmationEmail) { - await attendeeMail.sendEmail(); + try { + await attendeeMail.sendEmail(); + } catch (e) { + console.error("attendeeMail.sendEmail failed", e) + } } return { @@ -216,10 +224,18 @@ const updateMeeting = async (credential, uidToUpdate: String, calEvent: Calendar const organizerMail = new EventOrganizerRescheduledMail(calEvent, newUid); const attendeeMail = new EventAttendeeRescheduledMail(calEvent, newUid); - await organizerMail.sendEmail(); + try { + await organizerMail.sendEmail(); + } catch (e) { + console.error("organizerMail.sendEmail failed", e) + } if (!updateResult || !updateResult.disableConfirmationEmail) { - await attendeeMail.sendEmail(); + try { + await attendeeMail.sendEmail(); + } catch (e) { + console.error("attendeeMail.sendEmail failed", e) + } } return { diff --git a/pages/api/book/[user].ts b/pages/api/book/[user].ts index 9711f482b7..e5fcd285ba 100644 --- a/pages/api/book/[user].ts +++ b/pages/api/book/[user].ts @@ -93,7 +93,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) return updateEvent(credential, bookingRefUid, evt) .then(response => ({type: credential.type, success: true, response})) .catch(e => { - console.error("createEvent failed", e) + console.error("updateEvent failed", e) return {type: credential.type, success: false} }); })); @@ -103,12 +103,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) return updateMeeting(credential, bookingRefUid, evt) .then(response => ({type: credential.type, success: true, response})) .catch(e => { - console.error("createEvent failed", e) + console.error("updateMeeting failed", e) return {type: credential.type, success: false} }); })); - if (results.every(res => !res.success)) { + if (results.length > 0 && results.every(res => !res.success)) { res.status(500).json({message: "Rescheduling failed"}); return; } @@ -153,12 +153,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) return createMeeting(credential, evt) .then(response => ({type: credential.type, success: true, response})) .catch(e => { - console.error("createEvent failed", e) + console.error("createMeeting failed", e) return {type: credential.type, success: false} }); })); - if (results.every(res => !res.success)) { + if (results.length > 0 && results.every(res => !res.success)) { res.status(500).json({message: "Booking failed"}); return; } @@ -172,17 +172,19 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) } const hashUID = results.length > 0 ? results[0].response.uid : translator.fromUUID(uuidv5(JSON.stringify(evt), uuidv5.URL)); - try { - // TODO Should just be set to the true case as soon as we have a "bare email" integration class. - // UID generation should happen in the integration itself, not here. - if(results.length === 0) { - // Legacy as well, as soon as we have a separate email integration class. Just used - // to send an email even if there is no integration at all. + // TODO Should just be set to the true case as soon as we have a "bare email" integration class. + // UID generation should happen in the integration itself, not here. + if(results.length === 0) { + // Legacy as well, as soon as we have a separate email integration class. Just used + // to send an email even if there is no integration at all. + try { const mail = new EventAttendeeMail(evt, hashUID); await mail.sendEmail(); + } catch (e) { + console.error("Sending legacy event mail failed", e) + res.status(500).json({message: "Booking failed"}); + return; } - } catch (e) { - console.error("send EventAttendeeMail failed", e) } let booking;