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>
This commit is contained in:
authored and GitHub committed 2024-06-24 12:22:12 +00:00
1 parent ac05693694
commit f897c680a4
5 files changed
+41 -11

No files matched your search

+16
View File
@@ -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);
@@ -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);
+3 -3
View File
@@ -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";
@@ -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;
@@ -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;
@@ -2488,6 +2490,7 @@ async function handler(
uid: booking.uid,
},
data: {
location: evt.location,
metadata: { ...(typeof booking.metadata === "object" && booking.metadata), ...metadata },
references: {
createMany: {
@@ -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";
@@ -1132,7 +1132,7 @@ describe("handleNewBooking", () => {
],
},
],
apps: [TestData.apps["zoomvideo"]],
apps: [TestData.apps["zoomvideo"], TestData.apps["daily-video"]],
webhooks: [
{
userId: organizer.id,
@@ -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({
@@ -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
@@ -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}`,
});