Skip to content

Scheduling infrastructure for absolutely everyone.

Merge branch 'main' into bugfix/unify-email-sending

nicolasbd28636af57a
diff --cc lib/calendarClient.ts
index 7102a535bd9,9d3964b0d16..3ba2e86409e
--- a/lib/calendarClient.ts
+++ b/lib/calendarClient.ts
@@@ -509,26 -515,17 +519,31 @@@ const listCalendars = (withCredentials
results.reduce((acc, calendars) => acc.concat(calendars), [])
);
-const createEvent = async (credential: Credential, calEvent: CalendarEvent): Promise<unknown> => {
- const parser: CalEventParser = new CalEventParser(calEvent);
+const createEvent = async (
+ credential: Credential,
+ calEvent: CalendarEvent,
+ noMail = false,
+ maybeUid: string = null
+): Promise<EventResult> => {
+ const parser: CalEventParser = new CalEventParser(calEvent, maybeUid);
const uid: string = parser.getUid();
- const richEvent: CalendarEvent = parser.asRichEvent();
+ /*
+ * Matching the credential type is a workaround because the office calendar simply strips away newlines (\n and \r).
+ * We need HTML there. Google Calendar understands newlines and Apple Calendar cannot show HTML, so no HTML should
+ * be used for Google and Apple Calendar.
+ */
+ const richEvent: CalendarEvent = parser.asRichEventPlain();
- const creationResult = credential ? await calendars([credential])[0].createEvent(richEvent) : null;
+ let success = true;
+
+ const creationResult = credential
+ ? await calendars([credential])[0]
+ .createEvent(richEvent)
+ .catch((e) => {
+ log.error("createEvent failed", e, calEvent);
+ success = false;
+ })
+ : null;
const maybeHangoutLink = creationResult?.hangoutLink;
const maybeEntryPoints = creationResult?.entryPoints;
@@@ -574,39 -566,29 +589,39 @@@
const updateEvent = async (
credential: Credential,
uidToUpdate: string,
- calEvent: CalendarEvent
-): Promise<unknown> => {
+ calEvent: CalendarEvent,
+ noMail = false
+): Promise<EventResult> => {
const parser: CalEventParser = new CalEventParser(calEvent);
const newUid: string = parser.getUid();
- const richEvent: CalendarEvent = parser.asRichEvent();
+ const richEvent: CalendarEvent = parser.asRichEventPlain();
+ let success = true;
+
const updateResult = credential
- ? await calendars([credential])[0].updateEvent(uidToUpdate, richEvent)
+ ? await calendars([credential])[0]
+ .updateEvent(uidToUpdate, richEvent)
+ .catch((e) => {
+ log.error("updateEvent failed", e, calEvent);
+ success = false;
+ })
: null;
- const organizerMail = new EventOrganizerRescheduledMail(calEvent, newUid);
- const attendeeMail = new EventAttendeeRescheduledMail(calEvent, newUid);
- try {
- await organizerMail.sendEmail();
- } catch (e) {
- console.error("organizerMail.sendEmail failed", e);
- }
-
- if (!updateResult || !updateResult.disableConfirmationEmail) {
+ if (!noMail) {
+ const organizerMail = new EventOrganizerRescheduledMail(calEvent, newUid);
+ const attendeeMail = new EventAttendeeRescheduledMail(calEvent, newUid);
try {
- await attendeeMail.sendEmail();
+ await organizerMail.sendEmail();
} catch (e) {
- console.error("attendeeMail.sendEmail failed", e);
+ console.error("organizerMail.sendEmail failed", e);
+ }
+
+ if (!updateResult || !updateResult.disableConfirmationEmail) {
+ try {
+ await attendeeMail.sendEmail();
+ } catch (e) {
+ console.error("attendeeMail.sendEmail failed", e);
+ }
}
}