fix (#19298)
This commit is contained in:
@@ -3,12 +3,14 @@ import type { Prisma } from "@prisma/client";
|
||||
import EventManager from "@calcom/core/EventManager";
|
||||
import { sendScheduledEmailsAndSMS } from "@calcom/emails";
|
||||
import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation";
|
||||
import { getAllCredentials } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
|
||||
import { handleBookingRequested } from "@calcom/features/bookings/lib/handleBookingRequested";
|
||||
import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";
|
||||
import { HttpError as HttpCode } from "@calcom/lib/http-error";
|
||||
import { getBooking } from "@calcom/lib/payment/getBooking";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
import type { EventTypeMetadata } from "@calcom/prisma/zod-utils";
|
||||
import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import logger from "../logger";
|
||||
@@ -25,10 +27,15 @@ export async function handlePaymentSuccess(paymentId: number, bookingId: number)
|
||||
status: BookingStatus.ACCEPTED,
|
||||
};
|
||||
|
||||
const allCredentials = await getAllCredentials(userWithCredentials, {
|
||||
...eventType,
|
||||
metadata: eventType?.metadata as EventTypeMetadata,
|
||||
});
|
||||
|
||||
const isConfirmed = booking.status === BookingStatus.ACCEPTED;
|
||||
if (isConfirmed) {
|
||||
const apps = eventTypeAppMetadataOptionalSchema.parse(eventType?.metadata?.apps);
|
||||
const eventManager = new EventManager(userWithCredentials, apps);
|
||||
const eventManager = new EventManager({ ...userWithCredentials, credentials: allCredentials }, apps);
|
||||
const scheduleResult = await eventManager.create(evt);
|
||||
bookingData.references = { create: scheduleResult.referencesToCreate };
|
||||
}
|
||||
@@ -63,7 +70,7 @@ export async function handlePaymentSuccess(paymentId: number, bookingId: number)
|
||||
if (!isConfirmed) {
|
||||
if (!requiresConfirmation) {
|
||||
await handleConfirmation({
|
||||
user: userWithCredentials,
|
||||
user: { ...userWithCredentials, credentials: allCredentials },
|
||||
evt,
|
||||
prisma,
|
||||
bookingId: booking.id,
|
||||
|
||||
Reference in New Issue
Block a user