From 262738f28846265ec800fef5a70cae2de42b21b8 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Tue, 3 Dec 2024 00:30:43 +0530 Subject: [PATCH] fix: Meeting URL does not save when changing the location to Gmeet or any static app (#17840) * fix: meetingurl does not save when we change location * update * fix type error --------- Co-authored-by: Alex van Andel --- packages/lib/CalEventParser.ts | 5 ++- .../viewer/bookings/editLocation.handler.ts | 33 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/lib/CalEventParser.ts b/packages/lib/CalEventParser.ts index 5afa4ebd2b..d851f7f9f3 100644 --- a/packages/lib/CalEventParser.ts +++ b/packages/lib/CalEventParser.ts @@ -378,7 +378,7 @@ export const getPublicVideoCallUrl = (calEvent: Pick): str export const getVideoCallUrlFromCalEvent = ( calEvent: Parameters[0] & - Pick + Pick ): string => { if (calEvent.videoCallData) { if (isDailyVideoCall(calEvent)) { @@ -389,6 +389,9 @@ export const getVideoCallUrlFromCalEvent = ( if (calEvent.additionalInformation?.hangoutLink) { return calEvent.additionalInformation.hangoutLink; } + if (calEvent.location?.startsWith("http")) { + return calEvent.location; + } return ""; }; diff --git a/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts b/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts index 3bf85bbf7d..acf5e37cf2 100644 --- a/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts +++ b/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts @@ -10,7 +10,6 @@ import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; import { getTranslation } from "@calcom/lib/server"; import { getUsersCredentials } from "@calcom/lib/server/getUsersCredentials"; -import { BookingRepository } from "@calcom/lib/server/repository/booking"; import { CredentialRepository } from "@calcom/lib/server/repository/credential"; import { UserRepository } from "@calcom/lib/server/repository/user"; import { prisma } from "@calcom/prisma"; @@ -82,6 +81,7 @@ async function updateBookingLocationInDb({ booking: { id: number; metadata: Booking["metadata"]; + responses: Booking["responses"]; }; evt: Ensure; referencesToCreate: Prisma.BookingReferenceCreateInput[]; @@ -90,20 +90,6 @@ async function updateBookingLocationInDb({ videoCallUrl: getVideoCallUrlFromCalEvent(evt), }; - await BookingRepository.updateLocationById({ - data: { - location: evt.location, - metadata: { - ...(typeof booking.metadata === "object" && booking.metadata), - ...bookingMetadataUpdate, - }, - referencesToCreate, - }, - where: { - id: booking.id, - }, - }); - await prisma.booking.update({ where: { id: booking.id, @@ -117,6 +103,13 @@ async function updateBookingLocationInDb({ references: { create: referencesToCreate, }, + responses: { + ...(typeof booking.responses === "object" && booking.responses), + location: { + value: evt.location, + optionValue: "", + }, + }, }, }); } @@ -274,11 +267,17 @@ export async function editLocationHandler({ ctx, input }: EditLocationOptions) { evt, }); - await updateBookingLocationInDb({ booking, evt, referencesToCreate: updatedResult.referencesToCreate }); + const additionalInformation = extractAdditionalInformation(updatedResult.results[0]); + + await updateBookingLocationInDb({ + booking, + evt: { ...evt, additionalInformation }, + referencesToCreate: updatedResult.referencesToCreate, + }); try { await sendLocationChangeEmailsAndSMS( - { ...evt, additionalInformation: extractAdditionalInformation(updatedResult.results[0]) }, + { ...evt, additionalInformation }, booking?.eventType?.metadata as EventTypeMetadata ); } catch (error) {