Contains multiple fixes centered around Zoom (#3238)
This commit is contained in:
1 parent
9d951a5802
commit
3c7380c3a9
6 files changed
+79
-6
No files matched your search
@@ -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,
|
||||
},
|
||||
|
||||
@@ -334,6 +334,7 @@ const BookingPage = ({
|
||||
[recurringStrings, recurringDates] = parseRecurringDates(
|
||||
{
|
||||
startDate: date,
|
||||
timeZone: timeZone(),
|
||||
recurringEvent: eventType.recurringEvent,
|
||||
recurringCount: parseInt(recurringEventCount.toString()),
|
||||
},
|
||||
|
||||
@@ -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()];
|
||||
};
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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/meetingcreate
|
||||
return {
|
||||
topic: event.title,
|
||||
@@ -229,6 +292,7 @@ const ZoomVideoApiAdapter = (credential: Credential): VideoApiAdapter => {
|
||||
enforce_login: false,
|
||||
registrants_email_notification: true,
|
||||
},
|
||||
...recurrence,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user