Skip to content

Commit

Permalink
fix: Error changing location for meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
anikdhabal committed Dec 28, 2024
1 parent b0b93f6 commit 2e8d777
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import { getUsersCredentials } from "@calcom/lib/server/getUsersCredentials";
import { CredentialRepository } from "@calcom/lib/server/repository/credential";
import { UserRepository } from "@calcom/lib/server/repository/user";
import { prisma } from "@calcom/prisma";
import type { Prisma, Booking, BookingReference } from "@calcom/prisma/client";
import type { Booking, BookingReference } from "@calcom/prisma/client";
import type { userMetadata } from "@calcom/prisma/zod-utils";
import type { EventTypeMetadata } from "@calcom/prisma/zod-utils";
import type { AdditionalInformation, CalendarEvent } from "@calcom/types/Calendar";
import type { CredentialPayload } from "@calcom/types/Credential";
import type { PartialReference } from "@calcom/types/EventManager";
import type { Ensure } from "@calcom/types/utils";

import { TRPCError } from "@trpc/server";
Expand Down Expand Up @@ -76,19 +77,26 @@ function extractAdditionalInformation(result: {
async function updateBookingLocationInDb({
booking,
evt,
referencesToCreate,
references,
}: {
booking: {
id: number;
metadata: Booking["metadata"];
responses: Booking["responses"];
};
evt: Ensure<CalendarEvent, "location">;
referencesToCreate: Prisma.BookingReferenceCreateInput[];
references: PartialReference[];
}) {
const bookingMetadataUpdate = {
videoCallUrl: getVideoCallUrlFromCalEvent(evt),
};
const referencesToCreate = references.map((reference) => {
const { credentialId, ...restReference } = reference;
return {
...restReference,
...(credentialId && credentialId > 0 ? { credentialId } : {}),
};
});

await prisma.booking.update({
where: {
Expand Down Expand Up @@ -272,7 +280,7 @@ export async function editLocationHandler({ ctx, input }: EditLocationOptions) {
await updateBookingLocationInDb({
booking,
evt: { ...evt, additionalInformation },
referencesToCreate: updatedResult.referencesToCreate,
references: updatedResult.referencesToCreate,
});

try {
Expand Down

0 comments on commit 2e8d777

Please sign in to comment.