Skip to content

Commit

Permalink
fix: zoom shows up as location when expired instead of cal (#15153)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
  • Loading branch information
4 people authored Jun 24, 2024
1 parent 08f4a48 commit c44f243
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
16 changes: 16 additions & 0 deletions packages/core/EventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ export default class EventManager {
evt.videoCallData = result.createdEvent;
evt.location = result.originalEvent.location;
result.type = result.createdEvent.type;
//responses data is later sent to webhook
if (evt.location && evt.responses) {
evt.responses["location"].value = {
optionValue: "",
value: evt.location,
};
}
}

results.push(result);
Expand Down Expand Up @@ -224,6 +231,15 @@ export default class EventManager {
const result = await this.createVideoEvent(evt);
if (result.createdEvent) {
evt.videoCallData = result.createdEvent;
evt.location = result.originalEvent.location;
result.type = result.createdEvent.type;
//responses data is later sent to webhook
if (evt.location && evt.responses) {
evt.responses["location"].value = {
optionValue: "",
value: evt.location,
};
}
}

results.push(result);
Expand Down
6 changes: 3 additions & 3 deletions packages/core/videoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { v5 as uuidv5 } from "uuid";

import appStore from "@calcom/app-store";
import { getDailyAppKeys } from "@calcom/app-store/dailyvideo/lib/getDailyAppKeys";
import { DailyLocationType } from "@calcom/app-store/locations";
import { sendBrokenIntegrationEmail } from "@calcom/emails";
import { getUid } from "@calcom/lib/CalEventParser";
import logger from "@calcom/lib/logger";
Expand Down Expand Up @@ -114,14 +115,13 @@ const createMeeting = async (credential: CredentialPayload, calEvent: CalendarEv
safeStringify(err),
safeStringify({ calEvent: getPiiFreeCalendarEvent(calEvent) })
);

// Default to calVideo
const defaultMeeting = await createMeetingWithCalVideo(calEvent);
if (defaultMeeting) {
calEvent.location = "integrations:dailyvideo";
calEvent.location = DailyLocationType;
}

returnObject = { ...returnObject, createdEvent: defaultMeeting };
returnObject = { ...returnObject, originalEvent: calEvent, createdEvent: defaultMeeting };
}

return returnObject;
Expand Down
5 changes: 4 additions & 1 deletion packages/features/bookings/lib/handleNewBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,9 @@ async function handler(
} else if (isConfirmedByDefault) {
// Use EventManager to conditionally use all needed integrations.
const createManager = await eventManager.create(evt);

if (evt.location) {
booking.location = evt.location;
}
// This gets overridden when creating the event - to check if notes have been hidden or not. We just reset this back
// to the default description when we are sending the emails.
evt.description = eventType.description;
Expand Down Expand Up @@ -2488,6 +2490,7 @@ async function handler(
uid: booking.uid,
},
data: {
location: evt.location,
metadata: { ...(typeof booking.metadata === "object" && booking.metadata), ...metadata },
references: {
createMany: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ describe("handleNewBooking", () => {
);

test(
`Booking should still be created if booking with Zoom errors`,
`Booking should still be created using calvideo, if error occurs with zoom`,
async ({ emails }) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const subscriberUrl = "http://my-webhook.example.com";
Expand Down Expand Up @@ -1132,7 +1132,7 @@ describe("handleNewBooking", () => {
],
},
],
apps: [TestData.apps["zoomvideo"]],
apps: [TestData.apps["zoomvideo"], TestData.apps["daily-video"]],
webhooks: [
{
userId: organizer.id,
Expand All @@ -1150,6 +1150,15 @@ describe("handleNewBooking", () => {
metadataLookupKey: "zoomvideo",
});

mockSuccessfulVideoMeetingCreation({
metadataLookupKey: "dailyvideo",
videoMeetingData: {
id: "MOCK_ID",
password: "MOCK_PASS",
url: `http://mock-dailyvideo.example.com/meeting-1`,
},
});

const { req } = createMockNextJsRequest({
method: "POST",
body: getMockRequestDataForBooking({
Expand All @@ -1163,16 +1172,18 @@ describe("handleNewBooking", () => {
},
}),
});
await handleNewBooking(req);
const createdBooking = await handleNewBooking(req);

expect(createdBooking).toContain({
location: BookingLocations.CalVideo,
});
expectBrokenIntegrationEmails({ organizer, emails });

expectBookingCreatedWebhookToHaveBeenFired({
booker,
organizer,
location: BookingLocations.ZoomVideo,
location: BookingLocations.CalVideo,
subscriberUrl,
videoCallUrl: null,
videoCallUrl: `${WEBAPP_URL}/video/${createdBooking.uid}`,
});
},
timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ describe("handleNewBooking", () => {
expectBookingCreatedWebhookToHaveBeenFired({
booker,
organizer,
location: OrganizerDefaultConferencingAppType,
location: BookingLocations.CalVideo,
subscriberUrl: "http://my-webhook.example.com",
videoCallUrl: `${WEBAPP_URL}/video/${createdBooking.uid}`,
});
Expand Down

0 comments on commit c44f243

Please sign in to comment.