Skip to content

Commit f897c68

Browse files
Shaik-SirajuddinShaik-SirajuddinUdit-takkarsean-brydon
authored
fix: zoom shows up as location when expired instead of cal (#15153)
* fix:location doesn't match with meeting url when defaults to calvideo on app credentials expire * revert temporary logs * chore: use DailyLocationType * tests:modify exisiting tests --------- Co-authored-by: Shaik-Sirajuddin <sirajudddinshaik30@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
1 parent ac05693 commit f897c68

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

packages/core/EventManager.ts

+16
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ export default class EventManager {
163163
evt.videoCallData = result.createdEvent;
164164
evt.location = result.originalEvent.location;
165165
result.type = result.createdEvent.type;
166+
//responses data is later sent to webhook
167+
if (evt.location && evt.responses) {
168+
evt.responses["location"].value = {
169+
optionValue: "",
170+
value: evt.location,
171+
};
172+
}
166173
}
167174

168175
results.push(result);
@@ -224,6 +231,15 @@ export default class EventManager {
224231
const result = await this.createVideoEvent(evt);
225232
if (result.createdEvent) {
226233
evt.videoCallData = result.createdEvent;
234+
evt.location = result.originalEvent.location;
235+
result.type = result.createdEvent.type;
236+
//responses data is later sent to webhook
237+
if (evt.location && evt.responses) {
238+
evt.responses["location"].value = {
239+
optionValue: "",
240+
value: evt.location,
241+
};
242+
}
227243
}
228244

229245
results.push(result);

packages/core/videoClient.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { v5 as uuidv5 } from "uuid";
33

44
import appStore from "@calcom/app-store";
55
import { getDailyAppKeys } from "@calcom/app-store/dailyvideo/lib/getDailyAppKeys";
6+
import { DailyLocationType } from "@calcom/app-store/locations";
67
import { sendBrokenIntegrationEmail } from "@calcom/emails";
78
import { getUid } from "@calcom/lib/CalEventParser";
89
import logger from "@calcom/lib/logger";
@@ -114,14 +115,13 @@ const createMeeting = async (credential: CredentialPayload, calEvent: CalendarEv
114115
safeStringify(err),
115116
safeStringify({ calEvent: getPiiFreeCalendarEvent(calEvent) })
116117
);
117-
118118
// Default to calVideo
119119
const defaultMeeting = await createMeetingWithCalVideo(calEvent);
120120
if (defaultMeeting) {
121-
calEvent.location = "integrations:dailyvideo";
121+
calEvent.location = DailyLocationType;
122122
}
123123

124-
returnObject = { ...returnObject, createdEvent: defaultMeeting };
124+
returnObject = { ...returnObject, originalEvent: calEvent, createdEvent: defaultMeeting };
125125
}
126126

127127
return returnObject;

packages/features/bookings/lib/handleNewBooking.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,9 @@ async function handler(
21322132
} else if (isConfirmedByDefault) {
21332133
// Use EventManager to conditionally use all needed integrations.
21342134
const createManager = await eventManager.create(evt);
2135-
2135+
if (evt.location) {
2136+
booking.location = evt.location;
2137+
}
21362138
// This gets overridden when creating the event - to check if notes have been hidden or not. We just reset this back
21372139
// to the default description when we are sending the emails.
21382140
evt.description = eventType.description;
@@ -2488,6 +2490,7 @@ async function handler(
24882490
uid: booking.uid,
24892491
},
24902492
data: {
2493+
location: evt.location,
24912494
metadata: { ...(typeof booking.metadata === "object" && booking.metadata), ...metadata },
24922495
references: {
24932496
createMany: {

packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ describe("handleNewBooking", () => {
11001100
);
11011101

11021102
test(
1103-
`Booking should still be created if booking with Zoom errors`,
1103+
`Booking should still be created using calvideo, if error occurs with zoom`,
11041104
async ({ emails }) => {
11051105
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
11061106
const subscriberUrl = "http://my-webhook.example.com";
@@ -1132,7 +1132,7 @@ describe("handleNewBooking", () => {
11321132
],
11331133
},
11341134
],
1135-
apps: [TestData.apps["zoomvideo"]],
1135+
apps: [TestData.apps["zoomvideo"], TestData.apps["daily-video"]],
11361136
webhooks: [
11371137
{
11381138
userId: organizer.id,
@@ -1150,6 +1150,15 @@ describe("handleNewBooking", () => {
11501150
metadataLookupKey: "zoomvideo",
11511151
});
11521152

1153+
mockSuccessfulVideoMeetingCreation({
1154+
metadataLookupKey: "dailyvideo",
1155+
videoMeetingData: {
1156+
id: "MOCK_ID",
1157+
password: "MOCK_PASS",
1158+
url: `http://mock-dailyvideo.example.com/meeting-1`,
1159+
},
1160+
});
1161+
11531162
const { req } = createMockNextJsRequest({
11541163
method: "POST",
11551164
body: getMockRequestDataForBooking({
@@ -1163,16 +1172,18 @@ describe("handleNewBooking", () => {
11631172
},
11641173
}),
11651174
});
1166-
await handleNewBooking(req);
1175+
const createdBooking = await handleNewBooking(req);
11671176

1177+
expect(createdBooking).toContain({
1178+
location: BookingLocations.CalVideo,
1179+
});
11681180
expectBrokenIntegrationEmails({ organizer, emails });
1169-
11701181
expectBookingCreatedWebhookToHaveBeenFired({
11711182
booker,
11721183
organizer,
1173-
location: BookingLocations.ZoomVideo,
1184+
location: BookingLocations.CalVideo,
11741185
subscriberUrl,
1175-
videoCallUrl: null,
1186+
videoCallUrl: `${WEBAPP_URL}/video/${createdBooking.uid}`,
11761187
});
11771188
},
11781189
timeout

packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-scheduling.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ describe("handleNewBooking", () => {
12871287
expectBookingCreatedWebhookToHaveBeenFired({
12881288
booker,
12891289
organizer,
1290-
location: OrganizerDefaultConferencingAppType,
1290+
location: BookingLocations.CalVideo,
12911291
subscriberUrl: "http://my-webhook.example.com",
12921292
videoCallUrl: `${WEBAPP_URL}/video/${createdBooking.uid}`,
12931293
});

0 commit comments

Comments
 (0)