fix: use json.parse to get id (#4001)
* fix: use json.parse to get id * fix: type error * fix: add zod parse * chore: remove type Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
parent
52b2ce8774
commit
49a379ec6c
|
@ -2,11 +2,13 @@ import { Credential, DestinationCalendar } from "@prisma/client";
|
|||
import async from "async";
|
||||
import merge from "lodash/merge";
|
||||
import { v5 as uuidv5 } from "uuid";
|
||||
import { z } from "zod";
|
||||
|
||||
import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter";
|
||||
import { getEventLocationTypeFromApp } from "@calcom/app-store/locations";
|
||||
import getApps from "@calcom/app-store/utils";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { createdEventSchema } from "@calcom/prisma/zod-utils";
|
||||
import type { AdditionalInformation, CalendarEvent, NewCalendarEventType } from "@calcom/types/Calendar";
|
||||
import type { Event } from "@calcom/types/Event";
|
||||
import type {
|
||||
|
@ -61,6 +63,8 @@ type EventManagerUser = {
|
|||
destinationCalendar: DestinationCalendar | null;
|
||||
};
|
||||
|
||||
type createdEventSchema = z.infer<typeof createdEventSchema>;
|
||||
|
||||
export default class EventManager {
|
||||
calendarCredentials: Credential[];
|
||||
videoCredentials: Credential[];
|
||||
|
@ -102,12 +106,16 @@ export default class EventManager {
|
|||
results.push(...(await this.createAllCalendarEvents(evt)));
|
||||
|
||||
const referencesToCreate = results.map((result) => {
|
||||
let createdEventObj: createdEventSchema | null = null;
|
||||
if (typeof result?.createdEvent === "string") {
|
||||
createdEventObj = createdEventSchema.parse(JSON.parse(result.createdEvent));
|
||||
}
|
||||
return {
|
||||
type: result.type,
|
||||
uid: result.createdEvent?.id?.toString() ?? "",
|
||||
meetingId: result.createdEvent?.id?.toString(),
|
||||
meetingPassword: result.createdEvent?.password,
|
||||
meetingUrl: result.createdEvent?.url,
|
||||
uid: createdEventObj ? createdEventObj.id : result.createdEvent?.id?.toString() ?? "",
|
||||
meetingId: createdEventObj ? createdEventObj.id : result.createdEvent?.id?.toString(),
|
||||
meetingPassword: createdEventObj ? createdEventObj.password : result.createdEvent?.password,
|
||||
meetingUrl: createdEventObj ? createdEventObj.onlineMeetingUrl : result.createdEvent?.url,
|
||||
externalCalendarId: evt.destinationCalendar?.externalId,
|
||||
credentialId: evt.destinationCalendar?.credentialId,
|
||||
};
|
||||
|
|
|
@ -112,6 +112,14 @@ export const vitalSettingsUpdateSchema = z.object({
|
|||
sleepValue: z.number().optional(),
|
||||
});
|
||||
|
||||
export const createdEventSchema = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
password: z.union([z.string(), z.undefined()]),
|
||||
onlineMeetingUrl: z.string().nullable(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
export const userMetadata = z
|
||||
.object({
|
||||
proPaidForByTeamId: z.number().optional(),
|
||||
|
|
Loading…
Reference in New Issue
Block a user