Scheduling infrastructure for absolutely everyone.
Contains multiple fixes centered around Zoom (#3238)
Alex van Andel3c7380c3a94b
diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsxindex bfbb9d5a6ab..225bd1612b3 100644--- a/apps/web/components/booking/BookingListItem.tsx+++ b/apps/web/components/booking/BookingListItem.tsx@@ -206,6 +206,7 @@ function BookingListItem(booking: BookingItemProps) {[recurringStrings, recurringDates] = parseRecurringDates({startDate: booking.startTime,+ timeZone: user?.timeZone,recurringEvent: parseRecurringEvent(booking.eventType.recurringEvent),recurringCount: booking.recurringCount,},diff --git a/apps/web/components/booking/pages/BookingPage.tsx b/apps/web/components/booking/pages/BookingPage.tsxindex 0f9eb6110fc..affcee9ccd9 100644--- a/apps/web/components/booking/pages/BookingPage.tsx+++ b/apps/web/components/booking/pages/BookingPage.tsx@@ -334,6 +334,7 @@ const BookingPage = ({[recurringStrings, recurringDates] = parseRecurringDates({startDate: date,+ timeZone: timeZone(),recurringEvent: eventType.recurringEvent,recurringCount: parseInt(recurringEventCount.toString()),},diff --git a/apps/web/lib/parseDate.ts b/apps/web/lib/parseDate.tsindex 9fca8e30064..838e6f7957a 100644--- a/apps/web/lib/parseDate.ts+++ b/apps/web/lib/parseDate.ts@@ -23,9 +23,15 @@ export const parseDate = (date: string | null | Dayjs, i18n: I18n) => {export const parseRecurringDates = ({startDate,+ timeZone,recurringEvent,recurringCount,- }: { startDate: string | null | Dayjs; recurringEvent: RecurringEvent | null; recurringCount: number },+ }: {+ startDate: string | null | Dayjs;+ timeZone?: string;+ recurringEvent: RecurringEvent | null;+ recurringCount: number;+ },i18n: I18n): [string[], Date[]] => {// eslint-disable-next-line @typescript-eslint/no-unused-vars@@ -36,7 +42,7 @@ export const parseRecurringDates = (dtstart: dayjs(startDate).toDate(),});const dateStrings = rule.all().map((r) => {- return processDate(dayjs(r), i18n);+ return processDate(dayjs(r).tz(timeZone), i18n);});return [dateStrings, rule.all()];};diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.tsindex 3e4a751cd63..da9ca8794b4 100644--- a/apps/web/pages/api/book/event.ts+++ b/apps/web/pages/api/book/event.ts@@ -336,8 +336,8 @@ async function handler(req: NextApiRequest) {description: eventType.description,additionalNotes,customInputs,- startTime: reqBody.start,- endTime: reqBody.end,+ startTime: dayjs(reqBody.start).utc().format(),+ endTime: dayjs(reqBody.end).utc().format(),organizer: {name: organizerUser.name || "Nameless",email: organizerUser.email || "Email-less",@@ -490,8 +490,8 @@ async function handler(req: NextApiRequest) {const newBookingData: Prisma.BookingCreateInput = {uid,title: evt.title,- startTime: dayjs(evt.startTime).toDate(),- endTime: dayjs(evt.endTime).toDate(),+ startTime: dayjs.utc(evt.startTime).toDate(),+ endTime: dayjs.utc(evt.endTime).toDate(),description: evt.additionalNotes,customInputs: isPrismaObjOrUndefined(evt.customInputs),status: isConfirmedByDefault ? BookingStatus.ACCEPTED : BookingStatus.PENDING,diff --git a/apps/web/server/routers/viewer.tsx b/apps/web/server/routers/viewer.tsxindex 1a7a8754513..c1f2cc08926 100644--- a/apps/web/server/routers/viewer.tsx+++ b/apps/web/server/routers/viewer.tsx@@ -85,6 +85,7 @@ const loggedInViewerRouter = createProtectedRouter()bufferTime: user.bufferTime,locale: user.locale,timeFormat: user.timeFormat,+ timeZone: user.timeZone,avatar: user.avatar,createdDate: user.createdDate,trialEndsAt: user.trialEndsAt,diff --git a/packages/app-store/zoomvideo/lib/VideoApiAdapter.ts b/packages/app-store/zoomvideo/lib/VideoApiAdapter.tsindex 0a1fd5a253e..9292c20e648 100644--- a/packages/app-store/zoomvideo/lib/VideoApiAdapter.ts+++ b/packages/app-store/zoomvideo/lib/VideoApiAdapter.ts@@ -1,8 +1,10 @@import { Credential } from "@prisma/client";import { z } from "zod";+import dayjs from "@calcom/dayjs";import { handleErrorsJson } from "@calcom/lib/errors";import prisma from "@calcom/prisma";+import { Frequency } from "@calcom/prisma/zod-utils";import type { CalendarEvent } from "@calcom/types/Calendar";import type { PartialReference } from "@calcom/types/EventManager";import type { VideoApiAdapter, VideoCallData } from "@calcom/types/VideoApiAdapter";@@ -202,8 +204,69 @@ const zoomAuth = (credential: Credential) => {};};+type ZoomRecurrence = {+ end_date_time?: string;+ type: 1 | 2 | 3;+ end_times?: number;+ repeat_interval?: number;+ weekly_days?: number; // 1-7 Sunday = 1, Saturday = 7+ monthly_day?: number; // 1-31+};+const ZoomVideoApiAdapter = (credential: Credential): VideoApiAdapter => {const translateEvent = (event: CalendarEvent) => {+ const getRecurrence = ({+ recurringEvent,+ startTime,+ attendees,+ }: CalendarEvent): { recurrence: ZoomRecurrence; type: 8 } | undefined => {+ if (!recurringEvent) {+ return;+ }++ let recurrence: ZoomRecurrence;++ switch (recurringEvent.freq) {+ case Frequency.DAILY:+ recurrence = {+ type: 1,+ };+ break;+ case Frequency.WEEKLY:+ recurrence = {+ type: 2,+ weekly_days: dayjs(startTime).tz(attendees[0].timeZone).day() + 1,+ };+ break;+ case Frequency.MONTHLY:+ recurrence = {+ type: 3,+ monthly_day: dayjs(startTime).tz(attendees[0].timeZone).date(),+ };+ break;+ default:+ // Zoom does not support YEARLY, HOURLY or MINUTELY frequencies, don't do anything in those cases.+ return;+ }++ recurrence.repeat_interval = recurringEvent.interval;++ if (recurringEvent.until) {+ recurrence.end_date_time = recurringEvent.until.toISOString();+ } else {+ recurrence.end_times = recurringEvent.count;+ }++ return {+ recurrence: {+ ...recurrence,+ },+ type: 8,+ };+ };++ const recurrence = getRecurrence(event);+// Documentation at: https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreatereturn {topic: event.title,@@ -229,6 +292,7 @@ const ZoomVideoApiAdapter = (credential: Credential): VideoApiAdapter => {enforce_login: false,registrants_email_notification: true,},+ ...recurrence,};};