Hotfix: metadata parsing

Harsh/auto-add-url^2
zomars 2022-10-17 12:18:38 -06:00
parent 9842c18d50
commit aa038acafd
1 changed files with 9 additions and 13 deletions

View File

@ -9,7 +9,6 @@ import { deleteStripeCustomer } from "@calcom/app-store/stripepayment/lib/custom
import { getCustomerAndCheckoutSession } from "@calcom/app-store/stripepayment/lib/getCustomerAndCheckoutSession"; import { getCustomerAndCheckoutSession } from "@calcom/app-store/stripepayment/lib/getCustomerAndCheckoutSession";
import stripe, { closePayments } from "@calcom/app-store/stripepayment/lib/server"; import stripe, { closePayments } from "@calcom/app-store/stripepayment/lib/server";
import getApps, { getLocationOptions } from "@calcom/app-store/utils"; import getApps, { getLocationOptions } from "@calcom/app-store/utils";
import { getEventTypeAppData } from "@calcom/app-store/utils";
import { cancelScheduledJobs } from "@calcom/app-store/zapier/lib/nodeScheduler"; import { cancelScheduledJobs } from "@calcom/app-store/zapier/lib/nodeScheduler";
import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/CalendarManager"; import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/CalendarManager";
import { DailyLocationType } from "@calcom/core/location"; import { DailyLocationType } from "@calcom/core/location";
@ -39,7 +38,7 @@ import {
updateWebUser as syncServicesUpdateWebUser, updateWebUser as syncServicesUpdateWebUser,
} from "@calcom/lib/sync/SyncServiceManager"; } from "@calcom/lib/sync/SyncServiceManager";
import prisma, { baseEventTypeSelect, baseUserSelect, bookingMinimalSelect } from "@calcom/prisma"; import prisma, { baseEventTypeSelect, baseUserSelect, bookingMinimalSelect } from "@calcom/prisma";
import { userMetadata, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import { EventTypeMetaDataSchema, userMetadata } from "@calcom/prisma/zod-utils";
import { resizeBase64Image } from "@calcom/web/server/lib/resizeBase64Image"; import { resizeBase64Image } from "@calcom/web/server/lib/resizeBase64Image";
import { TRPCError } from "@trpc/server"; import { TRPCError } from "@trpc/server";
@ -349,10 +348,13 @@ const loggedInViewerRouter = createProtectedRouter()
throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" }); throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });
} }
const userEventTypes = user.eventTypes.map((eventType) => ({ const mapEventType = (eventType: typeof user.eventTypes[number]) => ({
...eventType, ...eventType,
metadata: EventTypeMetaDataSchema.parse(eventType.metadata), // @FIXME: cc @hariombalhara This is failing with production data
})); // metadata: EventTypeMetaDataSchema.parse(eventType.metadata),
});
const userEventTypes = user.eventTypes.map(mapEventType);
// backwards compatibility, TMP: // backwards compatibility, TMP:
const typesRaw = ( const typesRaw = (
await prisma.eventType.findMany({ await prisma.eventType.findMany({
@ -369,10 +371,7 @@ const loggedInViewerRouter = createProtectedRouter()
}, },
], ],
}) })
).map((eventType) => ({ ).map(mapEventType);
...eventType,
metadata: EventTypeMetaDataSchema.parse(eventType.metadata),
}));
type EventTypeGroup = { type EventTypeGroup = {
teamId?: number | null; teamId?: number | null;
@ -420,10 +419,7 @@ const loggedInViewerRouter = createProtectedRouter()
membershipCount: membership.team.members.length, membershipCount: membership.team.members.length,
readOnly: membership.role === MembershipRole.MEMBER, readOnly: membership.role === MembershipRole.MEMBER,
}, },
eventTypes: membership.team.eventTypes.map((eventType) => ({ eventTypes: membership.team.eventTypes.map(mapEventType),
...eventType,
metadata: EventTypeMetaDataSchema.parse(eventType.metadata),
})),
})) }))
); );
return { return {