fix: DelegationCredential - Duplicate GoogleMeet and unnecessary serviceAccount key access (#21269)

* Remove unused return statement

* Fix return from fn instead of continuing the loop

* Ensure userId is set for existing records on update

* ensure that serviceAccountKey is only retrieved whenb assked
This commit is contained in:
Hariom Balhara authored and GitHub committed 2025-05-14 09:49:47 +00:00
1 parent deb55c0536
commit df75df7008
32 files changed
+196 -113

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ import type Stripe from "stripe";
import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcom/emails";
import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation";
import { getAllCredentials } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";
import stripe from "@calcom/features/ee/payments/server/stripe";
import EventManager from "@calcom/lib/EventManager";
@@ -75,7 +75,7 @@ const handleSetupSuccess = async (event: Stripe.Event) => {
});
const metadata = eventTypeMetaDataSchemaWithTypedApps.parse(eventType?.metadata);
const allCredentials = await getAllCredentials(user, {
const allCredentials = await getAllCredentialsIncludeServiceAccountKey(user, {
...booking.eventType,
metadata,
});
@@ -3,7 +3,7 @@ import type { Prisma } from "@prisma/client";
import { metadata as GoogleMeetMetadata } from "@calcom/app-store/googlevideo/_metadata";
import { MeetLocationType } from "@calcom/app-store/locations";
import { getAllCredentials } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import type { EventType } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { getVideoCallDetails } from "@calcom/features/bookings/lib/handleNewBooking/getVideoCallDetails";
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
@@ -53,7 +53,10 @@ export const handleRescheduleEventManager = async ({
prefix: ["handleRescheduleEventManager", `${bookingId}`],
});
const allCredentials = await getAllCredentials(initParams.user, initParams?.eventType);
const allCredentials = await getAllCredentialsIncludeServiceAccountKey(
initParams.user,
initParams?.eventType
);
const eventManager = new EventManager(
{ ...initParams.user, credentials: allCredentials },
@@ -21,7 +21,7 @@ import {
import { scheduleWorkflowReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
import { SENDER_NAME } from "@calcom/lib/constants";
import { enrichUserWithDelegationCredentialsWithoutOrgId } from "@calcom/lib/delegationCredential/server";
import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server";
import { getEventName } from "@calcom/lib/event";
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj";
@@ -282,7 +282,7 @@ export const roundRobinManualReassignment = async ({
include: { user: { select: { email: true } } },
});
const newUserWithCredentials = await enrichUserWithDelegationCredentialsWithoutOrgId({
const newUserWithCredentials = await enrichUserWithDelegationCredentialsIncludeServiceAccountKey({
user: { ...newUser, credentials },
});
@@ -25,7 +25,7 @@ import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
import { SENDER_NAME } from "@calcom/lib/constants";
import {
enrichHostsWithDelegationCredentials,
enrichUserWithDelegationCredentialsWithoutOrgId,
enrichUserWithDelegationCredentialsIncludeServiceAccountKey,
} from "@calcom/lib/delegationCredential/server";
import { getEventName } from "@calcom/lib/event";
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
@@ -337,7 +337,7 @@ export const roundRobinReassignment = async ({
},
});
const organizerWithCredentials = await enrichUserWithDelegationCredentialsWithoutOrgId({
const organizerWithCredentials = await enrichUserWithDelegationCredentialsIncludeServiceAccountKey({
user: { ...organizer, credentials },
});