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>
This commit is contained in:
parent
99666440cf
commit
d960e03acf
1 changed files with 30 additions and 16 deletions
|
@ -72,21 +72,21 @@ export default class GoogleCalendarService implements Calendar {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
async createEvent(event: CalendarEvent): Promise<NewCalendarEventType> {
|
async createEvent(calEventRaw: CalendarEvent): Promise<NewCalendarEventType> {
|
||||||
return new Promise((resolve, reject) =>
|
return new Promise((resolve, reject) =>
|
||||||
this.auth.getToken().then((myGoogleAuth) => {
|
this.auth.getToken().then((myGoogleAuth) => {
|
||||||
const payload: calendar_v3.Schema$Event = {
|
const payload: calendar_v3.Schema$Event = {
|
||||||
summary: event.title,
|
summary: calEventRaw.title,
|
||||||
description: getRichDescription(event),
|
description: getRichDescription(calEventRaw),
|
||||||
start: {
|
start: {
|
||||||
dateTime: event.startTime,
|
dateTime: calEventRaw.startTime,
|
||||||
timeZone: event.organizer.timeZone,
|
timeZone: calEventRaw.organizer.timeZone,
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
dateTime: event.endTime,
|
dateTime: calEventRaw.endTime,
|
||||||
timeZone: event.organizer.timeZone,
|
timeZone: calEventRaw.organizer.timeZone,
|
||||||
},
|
},
|
||||||
attendees: event.attendees.map((attendee) => ({
|
attendees: calEventRaw.attendees.map((attendee) => ({
|
||||||
...attendee,
|
...attendee,
|
||||||
responseStatus: "accepted",
|
responseStatus: "accepted",
|
||||||
})),
|
})),
|
||||||
|
@ -95,23 +95,21 @@ export default class GoogleCalendarService implements Calendar {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (event.location) {
|
if (calEventRaw.location) {
|
||||||
payload["location"] = getLocation(event);
|
payload["location"] = getLocation(calEventRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.conferenceData && event.location === "integrations:google:meet") {
|
if (calEventRaw.conferenceData && calEventRaw.location === "integrations:google:meet") {
|
||||||
payload["conferenceData"] = event.conferenceData;
|
payload["conferenceData"] = calEventRaw.conferenceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const calendar = google.calendar({
|
const calendar = google.calendar({
|
||||||
version: "v3",
|
version: "v3",
|
||||||
auth: myGoogleAuth,
|
|
||||||
});
|
});
|
||||||
calendar.events.insert(
|
calendar.events.insert(
|
||||||
{
|
{
|
||||||
auth: myGoogleAuth,
|
auth: myGoogleAuth,
|
||||||
calendarId: event.destinationCalendar?.externalId
|
calendarId: calEventRaw.destinationCalendar?.externalId
|
||||||
? event.destinationCalendar.externalId
|
? calEventRaw.destinationCalendar.externalId
|
||||||
: "primary",
|
: "primary",
|
||||||
requestBody: payload,
|
requestBody: payload,
|
||||||
conferenceDataVersion: 1,
|
conferenceDataVersion: 1,
|
||||||
|
@ -121,6 +119,22 @@ export default class GoogleCalendarService implements Calendar {
|
||||||
console.error("There was an error contacting google calendar service: ", err);
|
console.error("There was an error contacting google calendar service: ", err);
|
||||||
return reject(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({
|
return resolve({
|
||||||
uid: "",
|
uid: "",
|
||||||
...event.data,
|
...event.data,
|
||||||
|
|
Loading…
Reference in a new issue