From d960e03acf492bf637e818143004d9cd83b45792 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Thu, 28 Apr 2022 15:54:31 +0100 Subject: [PATCH] Fixes google meet url not appearing calendar invite (#2636) * Update cal description * Tidy up console logs Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../googlecalendar/lib/CalendarService.ts | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/packages/app-store/googlecalendar/lib/CalendarService.ts b/packages/app-store/googlecalendar/lib/CalendarService.ts index 1e742aa35c..20fd3acc7a 100644 --- a/packages/app-store/googlecalendar/lib/CalendarService.ts +++ b/packages/app-store/googlecalendar/lib/CalendarService.ts @@ -72,21 +72,21 @@ export default class GoogleCalendarService implements Calendar { }; }; - async createEvent(event: CalendarEvent): Promise { + async createEvent(calEventRaw: CalendarEvent): Promise { return new Promise((resolve, reject) => this.auth.getToken().then((myGoogleAuth) => { const payload: calendar_v3.Schema$Event = { - summary: event.title, - description: getRichDescription(event), + summary: calEventRaw.title, + description: getRichDescription(calEventRaw), start: { - dateTime: event.startTime, - timeZone: event.organizer.timeZone, + dateTime: calEventRaw.startTime, + timeZone: calEventRaw.organizer.timeZone, }, end: { - dateTime: event.endTime, - timeZone: event.organizer.timeZone, + dateTime: calEventRaw.endTime, + timeZone: calEventRaw.organizer.timeZone, }, - attendees: event.attendees.map((attendee) => ({ + attendees: calEventRaw.attendees.map((attendee) => ({ ...attendee, responseStatus: "accepted", })), @@ -95,23 +95,21 @@ export default class GoogleCalendarService implements Calendar { }, }; - if (event.location) { - payload["location"] = getLocation(event); + if (calEventRaw.location) { + payload["location"] = getLocation(calEventRaw); } - if (event.conferenceData && event.location === "integrations:google:meet") { - payload["conferenceData"] = event.conferenceData; + if (calEventRaw.conferenceData && calEventRaw.location === "integrations:google:meet") { + payload["conferenceData"] = calEventRaw.conferenceData; } - const calendar = google.calendar({ version: "v3", - auth: myGoogleAuth, }); calendar.events.insert( { auth: myGoogleAuth, - calendarId: event.destinationCalendar?.externalId - ? event.destinationCalendar.externalId + calendarId: calEventRaw.destinationCalendar?.externalId + ? calEventRaw.destinationCalendar.externalId : "primary", requestBody: payload, conferenceDataVersion: 1, @@ -121,6 +119,22 @@ export default class GoogleCalendarService implements Calendar { console.error("There was an error contacting google calendar service: ", err); return reject(err); } + + calendar.events.patch({ + // Update the same event but this time we know the hangout link + calendarId: calEventRaw.destinationCalendar?.externalId + ? calEventRaw.destinationCalendar.externalId + : "primary", + auth: myGoogleAuth, + eventId: event.data.id || "", + requestBody: { + description: getRichDescription({ + ...calEventRaw, + additionInformation: { hangoutLink: event.data.hangoutLink || "" }, + }), + }, + }); + return resolve({ uid: "", ...event.data,