From 0a60a62910e1d05be4183eb7109a32a322f72737 Mon Sep 17 00:00:00 2001 From: nicolas Date: Thu, 22 Jul 2021 00:46:31 +0200 Subject: [PATCH] Conditionally use HTML --- lib/calendarClient.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/calendarClient.ts b/lib/calendarClient.ts index b64e0bf8..662b02e6 100644 --- a/lib/calendarClient.ts +++ b/lib/calendarClient.ts @@ -508,7 +508,13 @@ const listCalendars = (withCredentials) => const createEvent = async (credential: Credential, calEvent: CalendarEvent): Promise => { const parser: CalEventParser = new CalEventParser(calEvent); const uid: string = parser.getUid(); - const richEvent: CalendarEvent = parser.asRichEventPlain(); + /* + * 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 = + credential.type === "office365_calendar" ? parser.asRichEvent() : parser.asRichEventPlain(); const creationResult = credential ? await calendars([credential])[0].createEvent(richEvent) : null;