Set GCal & Outlook iCalUID in .ics file (#8010)

* Add calendar UID to calendar event

* Add iCalUID to booking event

* On reschedule write to evt the iCalUID

* Add uid to ics file

* Remove console logs

* Pass iCalUID if available

* Remove generated app store files

* Rename product id to calcom

* Add UID to ics on reschedule

* Type fixes

* Type fixes

* Type fixes

* Remove comment

* Remove console.log

* Removed serverConfig block from this branch

---------

Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
Joe Au-YeungandAlex van Andel authored and GitHub committed 2023-04-03 17:13:57 +00:00
1 parent fd84b5754d
commit 2e0951d4dc
12 files changed
+67 -21

No files matched your search

@@ -1057,6 +1057,10 @@ async function handler(
const results = updateManager.results;
const calendarResult = results.find((result) => result.type.includes("_calendar"));
evt.iCalUID = calendarResult.updatedEvent.iCalUID || undefined;
if (results.length > 0 && results.some((res) => !res.success)) {
const error = {
errorCode: "BookingReschedulingMeetingFailed",
@@ -1183,7 +1187,15 @@ async function handler(
const copyEvent = cloneDeep(evt);
await eventManager.reschedule(copyEvent, rescheduleUid, newTimeSlotBooking.id);
const updateManager = await eventManager.reschedule(copyEvent, rescheduleUid, newTimeSlotBooking.id);
const results = updateManager.results;
const calendarResult = results.find((result) => result.type.includes("_calendar"));
evt.iCalUID = Array.isArray(calendarResult?.updatedEvent)
? calendarResult?.updatedEvent[0]?.iCalUID
: calendarResult?.updatedEvent?.iCalUID || undefined;
// TODO send reschedule emails to attendees of the old booking
await sendRescheduledEmails({
@@ -1266,7 +1278,15 @@ async function handler(
const copyEvent = cloneDeep(evt);
await eventManager.reschedule(copyEvent, rescheduleUid, newTimeSlotBooking.id);
const updateManager = await eventManager.reschedule(copyEvent, rescheduleUid, newTimeSlotBooking.id);
const results = updateManager.results;
const calendarResult = results.find((result) => result.type.includes("_calendar"));
evt.iCalUID = Array.isArray(calendarResult?.updatedEvent)
? calendarResult?.updatedEvent[0]?.iCalUID
: calendarResult?.updatedEvent?.iCalUID || undefined;
await sendRescheduledSeatEmail(copyEvent, seatAttendee as Person);
const filteredAttendees = originalRescheduledBooking?.attendees.filter((attendee) => {
@@ -1575,7 +1595,7 @@ async function handler(
return prisma.booking.create(createBookingObj);
}
let results: EventResult<AdditionalInformation & { url?: string }>[] = [];
let results: EventResult<AdditionalInformation & { url?: string; iCalUID?: string }>[] = [];
let referencesToCreate: PartialReference[] = [];
type Booking = Prisma.PromiseReturnType<typeof createBooking>;
@@ -1716,6 +1736,11 @@ async function handler(
log.error(`Booking ${organizerUser.name} failed`, error, results);
} else {
const metadata: AdditionalInformation = {};
const calendarResult = results.find((result) => result.type.includes("_calendar"));
evt.iCalUID = Array.isArray(calendarResult?.updatedEvent)
? calendarResult?.updatedEvent[0]?.iCalUID
: calendarResult?.updatedEvent?.iCalUID || undefined;
if (results.length) {
// TODO: Handle created event metadata more elegantly