Skip to content

Commit a082cf7

Browse files
hariombalharaUdit-takkaranikdhabal
authored
fix: Manual RR reassign location change - Cal Video/Zoom/GoogleMeet to Zoom/Google Meet/Cal Video (calcom#22840)
* wip * fix tests * fix webex OAUTH_URL for local testing as done in other apps * fix type errors * Improve check --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
1 parent 61268f3 commit a082cf7

8 files changed

Lines changed: 1524 additions & 141 deletions

File tree

packages/app-store/locations.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* TODO: Consolidate this file with BookingLocationService and add tests
3+
*/
14
import type { TFunction } from "i18next";
25
import { z } from "zod";
36

@@ -58,7 +61,7 @@ export type EventLocationTypeFromApp = Ensure<
5861
export type EventLocationType = DefaultEventLocationType | EventLocationTypeFromApp;
5962

6063
export const DailyLocationType = "integrations:daily";
61-
64+
export const CalVideoLocationType = DailyLocationType;
6265
export const MeetLocationType = "integrations:google:meet";
6366

6467
export const MSTeamsLocationType = "integrations:office365_video";
@@ -380,7 +383,7 @@ export const getLocationValueForDB = (
380383
eventLocations: LocationObject[]
381384
) => {
382385
let bookingLocation = bookingLocationTypeOrValue;
383-
let conferenceCredentialId = undefined;
386+
let conferenceCredentialId: number | undefined = undefined;
384387

385388
eventLocations.forEach((location) => {
386389
if (location.type === bookingLocationTypeOrValue) {

packages/app-store/webex/api/add.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { NextApiRequest } from "next";
22
import { stringify } from "querystring";
33

4-
import { WEBAPP_URL } from "@calcom/lib/constants";
4+
import { WEBAPP_URL_FOR_OAUTH } from "@calcom/lib/constants";
55
import { defaultHandler } from "@calcom/lib/server/defaultHandler";
66
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
77
import prisma from "@calcom/prisma";
@@ -26,7 +26,7 @@ async function handler(req: NextApiRequest) {
2626
const params = {
2727
response_type: "code",
2828
client_id,
29-
redirect_uri: `${WEBAPP_URL}/api/integrations/${config.slug}/callback`,
29+
redirect_uri: `${WEBAPP_URL_FOR_OAUTH}/api/integrations/${config.slug}/callback`,
3030
scope: "spark:kms meeting:schedules_read meeting:schedules_write", //should be "A space-separated list of scopes being requested by your integration"
3131
state: "",
3232
};

packages/app-store/webex/api/callback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { NextApiRequest, NextApiResponse } from "next";
22

3-
import { WEBAPP_URL } from "@calcom/lib/constants";
3+
import { WEBAPP_URL_FOR_OAUTH } from "@calcom/lib/constants";
44
import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl";
55
import prisma from "@calcom/prisma";
66

@@ -17,7 +17,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
1717

1818
/** @link https://developer.webex.com/docs/integrations#getting-an-access-token **/
1919

20-
const redirectUri = encodeURI(`${WEBAPP_URL}/api/integrations/${config.slug}/callback`);
20+
const redirectUri = encodeURI(`${WEBAPP_URL_FOR_OAUTH}/api/integrations/${config.slug}/callback`);
2121
const params = new URLSearchParams([
2222
["grant_type", "authorization_code"],
2323
["client_id", client_id],

packages/features/ee/round-robin/handleRescheduleEventManager.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,24 @@ export const handleRescheduleEventManager = async ({
7373

7474
const results = updateManager.results ?? [];
7575

76+
const calVideoResult = results.find((result) => result.type === "daily_video");
77+
// Check if Cal Video Creation Failed - That is the fallback for Cal.com and is expected to always work
78+
if (calVideoResult && !calVideoResult.success) {
79+
handleRescheduleEventManager.error("Cal Video creation failed", {
80+
error: calVideoResult.error,
81+
bookingLocation,
82+
});
83+
// This happens only when Cal Video is down
84+
throw new Error("Failed to set video conferencing link, but the meeting has been rescheduled");
85+
}
86+
7687
const { metadata: videoMetadata, videoCallUrl: _videoCallUrl } = getVideoCallDetails({
7788
results: results,
7889
});
7990

8091
let videoCallUrl = _videoCallUrl;
8192
let metadata: AdditionalInformation = {};
8293
metadata = videoMetadata;
83-
8494
if (results.length) {
8595
// Handle Google Meet results
8696
if (bookingLocation === MeetLocationType) {
@@ -154,6 +164,7 @@ export const handleRescheduleEventManager = async ({
154164
? calendarResult?.updatedEvent[0]?.iCalUID
155165
: calendarResult?.updatedEvent?.iCalUID || undefined;
156166
}
167+
157168
const newReferencesToCreate = structuredClone(updateManager.referencesToCreate);
158169

159170
await BookingReferenceRepository.replaceBookingReferences({

0 commit comments

Comments
 (0)