fix/zoom schema parsing (#3274)

pull/3257/head^2
alannnc 2022-07-09 17:17:06 -06:00 committed by zomars
parent 9ad4cba8cf
commit 0b53cd6ffc
2 changed files with 7 additions and 108 deletions

View File

@ -12,112 +12,11 @@ import type { VideoApiAdapter, VideoCallData } from "@calcom/types/VideoApiAdapt
import { getZoomAppKeys } from "./getZoomAppKeys";
/** @link https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate */
export const zoomEventResultSchema = z
.object({
assistant_id: z.string(),
host_email: z.string(),
id: z.number(),
registration_url: z.string(),
agenda: z.string(),
created_at: z.string(),
duration: z.number(),
h323_password: z.string(),
join_url: z.string(),
occurrences: z.array(
z.object({
duration: z.number(),
occurrence_id: z.string(),
start_time: z.string(),
status: z.string(),
})
),
password: z.string(),
pmi: z.number(),
pre_schedule: z.boolean(),
recurrence: z.object({
end_date_time: z.string(),
end_times: z.number(),
monthly_day: z.number(),
monthly_week: z.number(),
monthly_week_day: z.number(),
repeat_interval: z.number(),
type: z.number(),
weekly_days: z.string(),
}),
settings: z.object({
allow_multiple_devices: z.boolean(),
alternative_hosts: z.string(),
alternative_hosts_email_notification: z.boolean(),
alternative_host_update_polls: z.boolean(),
approval_type: z.number(),
approved_or_denied_countries_or_regions: z.object({
approved_list: z.array(z.string()),
denied_list: z.array(z.string()),
enable: z.boolean(),
method: z.string(),
}),
audio: z.string(),
authentication_domains: z.string(),
authentication_exception: z.array(
z.object({ email: z.string(), name: z.string(), join_url: z.string() })
),
authentication_name: z.string(),
authentication_option: z.string(),
auto_recording: z.string(),
breakout_room: z.object({
enable: z.boolean(),
rooms: z.array(z.object({ name: z.string(), participants: z.array(z.string()) })),
}),
calendar_type: z.number(),
close_registration: z.boolean(),
cn_meeting: z.boolean(),
contact_email: z.string(),
contact_name: z.string(),
custom_keys: z.array(z.object({ key: z.string(), value: z.string() })),
email_notification: z.boolean(),
encryption_type: z.string(),
enforce_login: z.boolean(),
enforce_login_domains: z.string(),
focus_mode: z.boolean(),
global_dial_in_countries: z.array(z.string()),
global_dial_in_numbers: z.array(
z.object({
city: z.string(),
country: z.string(),
country_name: z.string(),
number: z.string(),
type: z.string(),
})
),
host_video: z.boolean(),
in_meeting: z.boolean(),
jbh_time: z.number(),
join_before_host: z.boolean(),
language_interpretation: z.object({
enable: z.boolean(),
interpreters: z.array(z.object({ email: z.string(), languages: z.string() })),
}),
meeting_authentication: z.boolean(),
mute_upon_entry: z.boolean(),
participant_video: z.boolean(),
private_meeting: z.boolean(),
registrants_confirmation_email: z.boolean(),
registrants_email_notification: z.boolean(),
registration_type: z.number(),
show_share_button: z.boolean(),
use_pmi: z.boolean(),
waiting_room: z.boolean(),
watermark: z.boolean(),
host_save_video_order: z.boolean(),
}),
start_time: z.string(),
start_url: z.string(),
timezone: z.string(),
topic: z.string(),
tracking_fields: z.array(z.object({ field: z.string(), value: z.string(), visible: z.boolean() })),
type: z.number(),
})
.deepPartial();
const zoomEventResultSchema = z.object({
id: z.number(),
join_url: z.string(),
password: z.string(),
});
export type ZoomEventResult = z.infer<typeof zoomEventResultSchema>;
@ -336,7 +235,7 @@ const ZoomVideoApiAdapter = (credential: Credential): VideoApiAdapter => {
body: JSON.stringify(translateEvent(event)),
});
const result = zoomEventResultSchema.passthrough().parse(response);
const result = zoomEventResultSchema.parse(response);
if (result.id && result.join_url) {
return Promise.resolve({
type: "zoom_video",

View File

@ -46,7 +46,7 @@ const createMeeting = async (credential: Credential, calEvent: CalendarEvent) =>
const [firstVideoAdapter] = videoAdapters;
const createdMeeting = await firstVideoAdapter.createMeeting(calEvent).catch(async (e) => {
await sendBrokenIntegrationEmail(calEvent, "video");
log.error("createMeeting failed", e, calEvent);
console.error("createMeeting failed", e, calEvent);
});
if (!createdMeeting) {