chore: [Booking Flow Refactor - 5] Move post booking things to separate service BookingEventHandlerService starting with HashedLink usage handling (#24025)
* chore: Move post booking stuff to separate service * refactor: improve ISP compliance in BookingEventHandlerService - Refactor updatePrivateLinkUsage to only accept hashedLink parameter instead of full payload - Remove shouldProcess function and inline isDryRun check for better clarity - Addresses feedback from PR #24025 Co-Authored-By: [email protected] <[email protected]> * define only what is used * Define hashed-link-service as well in api-v2 * fix: export HashedLinkService through platform-libraries - Add HashedLinkService to platform-libraries/private-links.ts - Update API V2 to import from platform library instead of direct path - Fixes MODULE_NOT_FOUND error in API V2 build Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Morgan <[email protected]>
This commit is contained in:
27 files changed
+763
-60
No files matched your search
@@ -7,6 +7,7 @@ import { PrismaUserRepository } from "@/lib/repositories/prisma-user.repository"
|
||||
import { CacheService } from "@/lib/services/cache.service";
|
||||
import { CheckBookingAndDurationLimitsService } from "@/lib/services/check-booking-and-duration-limits.service";
|
||||
import { CheckBookingLimitsService } from "@/lib/services/check-booking-limits.service";
|
||||
import { HashedLinkService } from "@/lib/services/hashed-link.service";
|
||||
import { LuckyUserService } from "@/lib/services/lucky-user.service";
|
||||
import { RegularBookingService } from "@/lib/services/regular-booking.service";
|
||||
import { PrismaModule } from "@/modules/prisma/prisma.module";
|
||||
@@ -24,9 +25,10 @@ import { Module } from "@nestjs/common";
|
||||
CacheService,
|
||||
CheckBookingAndDurationLimitsService,
|
||||
CheckBookingLimitsService,
|
||||
HashedLinkService,
|
||||
LuckyUserService,
|
||||
RegularBookingService,
|
||||
],
|
||||
exports: [RegularBookingService],
|
||||
})
|
||||
export class RegularBookingModule {}
|
||||
export class RegularBookingModule { }
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { HashedLinkService as BaseHashedLinkService } from "@calcom/platform-libraries/private-links";
|
||||
|
||||
@Injectable()
|
||||
export class HashedLinkService extends BaseHashedLinkService {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { PrismaBookingRepository } from "@/lib/repositories/prisma-booking.repos
|
||||
import { PrismaUserRepository } from "@/lib/repositories/prisma-user.repository";
|
||||
import { CacheService } from "@/lib/services/cache.service";
|
||||
import { CheckBookingAndDurationLimitsService } from "@/lib/services/check-booking-and-duration-limits.service";
|
||||
import { HashedLinkService } from "@/lib/services/hashed-link.service";
|
||||
import { LuckyUserService } from "@/lib/services/lucky-user.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
@@ -16,6 +17,7 @@ export class RegularBookingService extends BaseRegularBookingService {
|
||||
checkBookingAndDurationLimitsService: CheckBookingAndDurationLimitsService,
|
||||
prismaWriteService: PrismaWriteService,
|
||||
bookingRepository: PrismaBookingRepository,
|
||||
hashedLinkService: HashedLinkService,
|
||||
luckyUserService: LuckyUserService,
|
||||
userRepository: PrismaUserRepository
|
||||
) {
|
||||
@@ -24,6 +26,7 @@ export class RegularBookingService extends BaseRegularBookingService {
|
||||
checkBookingAndDurationLimitsService,
|
||||
prismaClient: prismaWriteService.prisma as unknown as PrismaClient,
|
||||
bookingRepository,
|
||||
hashedLinkService,
|
||||
luckyUserService,
|
||||
userRepository,
|
||||
});
|
||||
|
||||
@@ -8,12 +8,12 @@ import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import { EventRepository } from "@calcom/features/eventtypes/repositories/EventRepository";
|
||||
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/services/hashedLinkService";
|
||||
import {
|
||||
shouldHideBrandingForTeamEvent,
|
||||
shouldHideBrandingForUserEvent,
|
||||
} from "@calcom/features/profile/lib/hideBranding";
|
||||
import { UserRepository } from "@calcom/features/users/repositories/UserRepository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/lib/service/HashedLinkService";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { RedirectType } from "@calcom/prisma/enums";
|
||||
@@ -82,9 +82,8 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
redirect: {
|
||||
permanent: false,
|
||||
// App Router doesn't have access to the current path directly, so we build it manually
|
||||
destination: `${redirectWithOriginAndSearchString.origin ?? ""}/d/${link}/${slug}${
|
||||
redirectWithOriginAndSearchString.searchString
|
||||
}`,
|
||||
destination: `${redirectWithOriginAndSearchString.origin ?? ""}/d/${link}/${slug}${redirectWithOriginAndSearchString.searchString
|
||||
}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ export function getBasicMockRequestDataForBooking() {
|
||||
user: "teampro",
|
||||
metadata: {},
|
||||
hasHashedBookingLink: false,
|
||||
hashedLink: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,6 +34,9 @@ type CommonPropsMockRequestData = {
|
||||
attendeePhoneNumber?: string;
|
||||
smsReminderNumber?: string;
|
||||
};
|
||||
_isDryRun?: boolean;
|
||||
hashedLink?: string;
|
||||
hasHashedBookingLink?: boolean;
|
||||
};
|
||||
|
||||
export function getMockRequestDataForBooking({
|
||||
|
||||
@@ -6,6 +6,7 @@ import { moduleLoader as checkBookingAndDurationLimitsModuleLoader } from "@calc
|
||||
import { moduleLoader as luckyUserServiceModuleLoader } from "@calcom/features/di/modules/LuckyUser";
|
||||
import { moduleLoader as userRepositoryModuleLoader } from "@calcom/features/di/modules/User";
|
||||
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
import { moduleLoader as hashedLinkServiceModuleLoader } from "@calcom/features/hashedLink/di/HashedLinkService.module";
|
||||
import { moduleLoader as prismaModuleLoader } from "@calcom/prisma/prisma.module";
|
||||
|
||||
const thisModule = createModule();
|
||||
@@ -24,6 +25,7 @@ const loadModule = bindModuleToClassOnToken({
|
||||
bookingRepository: bookingRepositoryModuleLoader,
|
||||
luckyUserService: luckyUserServiceModuleLoader,
|
||||
userRepository: userRepositoryModuleLoader,
|
||||
hashedLinkService: hashedLinkServiceModuleLoader,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -54,3 +54,8 @@ export type InstantBookingCreateResult = {
|
||||
expires: Date;
|
||||
userId: number | null;
|
||||
};
|
||||
|
||||
// More properties to be added to this config in followup PRs
|
||||
export type BookingFlowConfig = {
|
||||
isDryRun: boolean;
|
||||
};
|
||||
@@ -0,0 +1,473 @@
|
||||
/**
|
||||
* Post-Booking handling tests
|
||||
*
|
||||
* These tests focus specifically on testing what happens after a successful booking or rescheduling.
|
||||
*/
|
||||
import prismaMock from "../../../../../../tests/libs/__mocks__/prisma";
|
||||
|
||||
import {
|
||||
createBookingScenario,
|
||||
getDate,
|
||||
getGoogleCalendarCredential,
|
||||
TestData,
|
||||
getOrganizer,
|
||||
getBooker,
|
||||
getScenarioData,
|
||||
mockCalendarToHaveNoBusySlots,
|
||||
BookingLocations,
|
||||
} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
||||
import { expectBookingToBeInDatabase } from "@calcom/web/test/utils/bookingScenario/expects";
|
||||
import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
|
||||
import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
|
||||
|
||||
import type { Request, Response } from "express";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { describe, expect, beforeEach, vi, test } from "vitest";
|
||||
|
||||
import { resetTestEmails } from "@calcom/lib/testEmails";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
|
||||
import { getNewBookingHandler } from "./getNewBookingHandler";
|
||||
|
||||
export type CustomNextApiRequest = NextApiRequest & Request;
|
||||
export type CustomNextApiResponse = NextApiResponse & Response;
|
||||
|
||||
// Local test runs sometimes get too slow
|
||||
const timeout = process.env.CI ? 5000 : 20000;
|
||||
|
||||
// Helper function to create hashed link test data
|
||||
function createHashedLinkTestData({
|
||||
eventTypeId,
|
||||
usageLimit = 5,
|
||||
currentUsage = 0,
|
||||
}: {
|
||||
eventTypeId: number;
|
||||
usageLimit?: number;
|
||||
currentUsage?: number;
|
||||
}) {
|
||||
const link = "test-hashed-link-abc123";
|
||||
return {
|
||||
id: 1,
|
||||
link,
|
||||
eventTypeId,
|
||||
maxUsageCount: usageLimit,
|
||||
usageCount: currentUsage,
|
||||
expiresAt: null,
|
||||
};
|
||||
}
|
||||
|
||||
// Helper function to verify hashed link usage count
|
||||
async function expectHashedLinkUsageToBe(linkId: string, expectedUsageCount: number) {
|
||||
const hashedLink = await prismaMock.hashedLink.findUnique({
|
||||
where: { link: linkId },
|
||||
});
|
||||
expect(hashedLink?.usageCount).toBe(expectedUsageCount);
|
||||
}
|
||||
|
||||
describe("Post-Booking Events - Hashed Link Usage", () => {
|
||||
setupAndTeardown();
|
||||
beforeEach(() => {
|
||||
// Reset test state before each test
|
||||
resetTestEmails();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("BookingEventHandler Hashed Link Usage Tracking", () => {
|
||||
test(
|
||||
`should increment hashed link usage when booking is created with hashed link
|
||||
1. Should create a booking in the database
|
||||
2. Should increment hashed link usage count via BookingEventHandler.onBookingCreated
|
||||
`,
|
||||
async () => {
|
||||
const handleNewBooking = getNewBookingHandler();
|
||||
const booker = getBooker({
|
||||
email: "[email protected]",
|
||||
name: "Booker",
|
||||
});
|
||||
|
||||
const organizer = getOrganizer({
|
||||
name: "Organizer",
|
||||
email: "[email protected]",
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
});
|
||||
|
||||
const hashedLinkData = createHashedLinkTestData({
|
||||
eventTypeId: 1,
|
||||
usageLimit: 5,
|
||||
currentUsage: 2, // Should be incremented to 3 after booking
|
||||
});
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slotInterval: 45,
|
||||
length: 30,
|
||||
users: [
|
||||
{
|
||||
id: 101,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
users: [organizer],
|
||||
})
|
||||
);
|
||||
|
||||
// Create the hashed link in the database
|
||||
await prismaMock.hashedLink.create({
|
||||
data: hashedLinkData,
|
||||
});
|
||||
|
||||
mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
uid: "HASHED_LINK_BOOKING_UID",
|
||||
},
|
||||
update: {
|
||||
iCalUID: "HASHED_LINK_BOOKING_UID",
|
||||
uid: "HASHED_LINK_BOOKING_UID",
|
||||
},
|
||||
});
|
||||
|
||||
const mockBookingRequest = getMockRequestDataForBooking({
|
||||
data: {
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
hashedLink: hashedLinkData.link,
|
||||
hasHashedBookingLink: true,
|
||||
},
|
||||
});
|
||||
|
||||
const bookingResponse = await handleNewBooking({
|
||||
bookingData: mockBookingRequest,
|
||||
});
|
||||
|
||||
await expectBookingToBeInDatabase({
|
||||
description: "",
|
||||
uid: bookingResponse.uid,
|
||||
location: BookingLocations.CalVideo,
|
||||
responses: expect.objectContaining({
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
}),
|
||||
status: BookingStatus.ACCEPTED,
|
||||
});
|
||||
|
||||
await expectHashedLinkUsageToBe(hashedLinkData.link, hashedLinkData.usageCount + 1);
|
||||
|
||||
expect(bookingResponse.status).toEqual(BookingStatus.ACCEPTED);
|
||||
expect(bookingResponse.uid).toBeDefined();
|
||||
},
|
||||
timeout
|
||||
);
|
||||
|
||||
test(
|
||||
`should increment hashed link usage when rescheduling a booking with hashed link
|
||||
1. Should reschedule the booking in the database
|
||||
2. Should increment hashed link usage count via BookingEventHandler.onBookingRescheduled
|
||||
`,
|
||||
async () => {
|
||||
const handleNewBooking = getNewBookingHandler();
|
||||
const booker = getBooker({
|
||||
email: "[email protected]",
|
||||
name: "Booker",
|
||||
});
|
||||
|
||||
const organizer = getOrganizer({
|
||||
name: "Organizer",
|
||||
email: "[email protected]",
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
});
|
||||
|
||||
const hashedLinkData = createHashedLinkTestData({
|
||||
eventTypeId: 1,
|
||||
usageLimit: 5,
|
||||
currentUsage: 2,
|
||||
});
|
||||
|
||||
// Create an existing booking to reschedule
|
||||
const existingBookingUid = "existing-booking-uid";
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slotInterval: 45,
|
||||
length: 30,
|
||||
users: [
|
||||
{
|
||||
id: 101,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
users: [organizer],
|
||||
bookings: [
|
||||
{
|
||||
uid: existingBookingUid,
|
||||
eventTypeId: 1,
|
||||
userId: organizer.id,
|
||||
status: BookingStatus.ACCEPTED,
|
||||
startTime: `${getDate({ dateIncrement: 1 }).dateString}T05:00:00.000Z`,
|
||||
endTime: `${getDate({ dateIncrement: 1 }).dateString}T05:45:00.000Z`,
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
// Create the hashed link in the database
|
||||
await prismaMock.hashedLink.create({
|
||||
data: hashedLinkData,
|
||||
});
|
||||
|
||||
mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
uid: "RESCHEDULED_BOOKING_UID",
|
||||
},
|
||||
update: {
|
||||
iCalUID: "RESCHEDULED_BOOKING_UID",
|
||||
uid: "RESCHEDULED_BOOKING_UID",
|
||||
},
|
||||
});
|
||||
|
||||
const mockBookingData = getMockRequestDataForBooking({
|
||||
data: {
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
hashedLink: hashedLinkData.link,
|
||||
hasHashedBookingLink: true,
|
||||
rescheduleUid: existingBookingUid,
|
||||
},
|
||||
});
|
||||
|
||||
const bookingResponse = await handleNewBooking({
|
||||
bookingData: mockBookingData,
|
||||
});
|
||||
|
||||
if (bookingResponse.uid) {
|
||||
await expectBookingToBeInDatabase({
|
||||
description: "",
|
||||
location: BookingLocations.CalVideo,
|
||||
responses: expect.objectContaining({
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
}),
|
||||
status: BookingStatus.ACCEPTED,
|
||||
uid: bookingResponse.uid,
|
||||
});
|
||||
}
|
||||
|
||||
await expectHashedLinkUsageToBe(hashedLinkData.link, hashedLinkData.usageCount + 1);
|
||||
|
||||
expect(bookingResponse.status).toEqual(BookingStatus.ACCEPTED);
|
||||
expect(bookingResponse.uid).toBeDefined();
|
||||
},
|
||||
timeout
|
||||
);
|
||||
|
||||
test(
|
||||
`should not increment hashed link usage during dry run
|
||||
1. Should not increment hashed link usage (BookingEventHandler should skip processing)
|
||||
`,
|
||||
async () => {
|
||||
const handleNewBooking = getNewBookingHandler();
|
||||
const booker = getBooker({
|
||||
email: "[email protected]",
|
||||
name: "Booker",
|
||||
});
|
||||
|
||||
const organizer = getOrganizer({
|
||||
name: "Organizer",
|
||||
email: "[email protected]",
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
});
|
||||
|
||||
const hashedLinkData = createHashedLinkTestData({
|
||||
eventTypeId: 1,
|
||||
usageLimit: 5,
|
||||
currentUsage: 2,
|
||||
});
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slotInterval: 45,
|
||||
length: 30,
|
||||
users: [
|
||||
{
|
||||
id: 101,
|
||||
},
|
||||
],
|
||||
// hashedLink will be created separately in database
|
||||
},
|
||||
],
|
||||
users: [organizer],
|
||||
})
|
||||
);
|
||||
|
||||
mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
uid: "DRY_RUN_BOOKING_UID",
|
||||
},
|
||||
});
|
||||
|
||||
// Create the hashed link in the database
|
||||
await prismaMock.hashedLink.create({
|
||||
data: hashedLinkData,
|
||||
});
|
||||
|
||||
const mockBookingData = getMockRequestDataForBooking({
|
||||
data: {
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
hashedLink: hashedLinkData.link,
|
||||
hasHashedBookingLink: true,
|
||||
_isDryRun: true,
|
||||
},
|
||||
});
|
||||
|
||||
const bookingResponse = await handleNewBooking({
|
||||
bookingData: mockBookingData,
|
||||
});
|
||||
|
||||
expect(bookingResponse.uid).toBe("DRY_RUN_UID");
|
||||
// Verify hashed link usage was NOT incremented during dry run
|
||||
await expectHashedLinkUsageToBe(hashedLinkData.link, hashedLinkData.usageCount);
|
||||
|
||||
expect(bookingResponse.status).toEqual(BookingStatus.ACCEPTED);
|
||||
},
|
||||
timeout
|
||||
);
|
||||
|
||||
test(
|
||||
`should handle hashed link service errors gracefully without failing booking creation
|
||||
1. Should create a booking successfully
|
||||
2. Should handle hashed link service errors gracefully in BookingEventHandler
|
||||
3. Should log errors but continue booking flow
|
||||
`,
|
||||
async () => {
|
||||
const handleNewBooking = getNewBookingHandler();
|
||||
const booker = getBooker({
|
||||
email: "[email protected]",
|
||||
name: "Booker",
|
||||
});
|
||||
|
||||
const organizer = getOrganizer({
|
||||
name: "Organizer",
|
||||
email: "[email protected]",
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
});
|
||||
|
||||
const hashedLinkData = createHashedLinkTestData({
|
||||
eventTypeId: 1,
|
||||
usageLimit: 5,
|
||||
currentUsage: 2,
|
||||
});
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slotInterval: 45,
|
||||
length: 30,
|
||||
users: [
|
||||
{
|
||||
id: 101,
|
||||
},
|
||||
],
|
||||
// hashedLink will be created separately in database
|
||||
},
|
||||
],
|
||||
users: [organizer],
|
||||
})
|
||||
);
|
||||
|
||||
mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
uid: "ERROR_HANDLING_BOOKING_UID",
|
||||
},
|
||||
update: {
|
||||
iCalUID: "ERROR_HANDLING_BOOKING_UID",
|
||||
uid: "ERROR_HANDLING_BOOKING_UID",
|
||||
},
|
||||
});
|
||||
|
||||
// Create an invalid hashed link that will cause validation to fail
|
||||
// (maxUsageCount = 0 means it should be expired)
|
||||
const invalidHashedLinkData = {
|
||||
...hashedLinkData,
|
||||
maxUsageCount: 0, // This will cause validation to fail
|
||||
};
|
||||
|
||||
await prismaMock.hashedLink.create({
|
||||
data: invalidHashedLinkData,
|
||||
});
|
||||
|
||||
const mockBookingRequest = getMockRequestDataForBooking({
|
||||
data: {
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
hasHashedBookingLink: true,
|
||||
hashedLink: hashedLinkData.link,
|
||||
},
|
||||
});
|
||||
|
||||
const bookingResponse = await handleNewBooking({
|
||||
bookingData: mockBookingRequest,
|
||||
});
|
||||
|
||||
// Booking should still be created successfully despite hashed link error
|
||||
await expectBookingToBeInDatabase({
|
||||
description: "",
|
||||
uid: bookingResponse.uid,
|
||||
location: BookingLocations.CalVideo,
|
||||
responses: expect.objectContaining({
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
}),
|
||||
status: BookingStatus.ACCEPTED,
|
||||
});
|
||||
|
||||
// Verify that even though hashed link processing failed,
|
||||
await expectHashedLinkUsageToBe(hashedLinkData.link, invalidHashedLinkData.usageCount);
|
||||
|
||||
expect(bookingResponse.status).toEqual(BookingStatus.ACCEPTED);
|
||||
expect(bookingResponse.uid).toBeDefined();
|
||||
},
|
||||
timeout
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import type { Logger } from "tslog";
|
||||
|
||||
import type { HashedLinkService } from "@calcom/features/hashedLink/lib/service/HashedLinkService";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
|
||||
import type { BookingCreatedPayload, BookingRescheduledPayload } from "./types";
|
||||
|
||||
interface BookingEventHandlerDeps {
|
||||
log: Logger<unknown>;
|
||||
hashedLinkService: HashedLinkService;
|
||||
}
|
||||
|
||||
export class BookingEventHandlerService {
|
||||
private readonly log: BookingEventHandlerDeps["log"];
|
||||
private readonly hashedLinkService: BookingEventHandlerDeps["hashedLinkService"];
|
||||
|
||||
constructor(private readonly deps: BookingEventHandlerDeps) {
|
||||
this.log = deps.log;
|
||||
this.hashedLinkService = deps.hashedLinkService;
|
||||
}
|
||||
|
||||
async onBookingCreated(payload: BookingCreatedPayload) {
|
||||
this.log.debug("onBookingCreated", safeStringify(payload));
|
||||
if (payload.config.isDryRun) {
|
||||
return;
|
||||
}
|
||||
await this.onBookingCreatedOrRescheduled(payload);
|
||||
}
|
||||
|
||||
async onBookingRescheduled(payload: BookingRescheduledPayload) {
|
||||
this.log.debug("onBookingRescheduled", safeStringify(payload));
|
||||
if (payload.config.isDryRun) {
|
||||
return;
|
||||
}
|
||||
await this.onBookingCreatedOrRescheduled(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles common tasks that need to be executed in both booking created and rescheduled events
|
||||
* A dedicated place because there are many tasks that need to be executed in both events.
|
||||
*/
|
||||
private async onBookingCreatedOrRescheduled(payload: BookingCreatedPayload | BookingRescheduledPayload) {
|
||||
const results = await Promise.allSettled([
|
||||
// TODO: Migrate other post-booking tasks here, to execute them in parallel, without affecting each other
|
||||
this.updatePrivateLinkUsage(payload.bookingFormData.hashedLink),
|
||||
]);
|
||||
results.forEach((result) => {
|
||||
if (result.status === "rejected") {
|
||||
this.log.error(
|
||||
"Error while executing onBookingCreatedOrRescheduled task",
|
||||
safeStringify(result.reason)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async updatePrivateLinkUsage(hashedLink: string | null) {
|
||||
try {
|
||||
if (hashedLink) {
|
||||
await this.deps.hashedLinkService.validateAndIncrementUsage(hashedLink);
|
||||
}
|
||||
} catch (error) {
|
||||
this.log.error("Error while updating hashed link", safeStringify(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { BookingFlowConfig } from "./dto/types";
|
||||
|
||||
export interface BookingCreatedPayload {
|
||||
config: BookingFlowConfig;
|
||||
bookingFormData: {
|
||||
hashedLink: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
// Add more fields here when needed
|
||||
type BookingRescheduledPayload = BookingCreatedPayload;
|
||||
@@ -33,6 +33,7 @@ import type { CheckBookingAndDurationLimitsService } from "@calcom/features/book
|
||||
import { handlePayment } from "@calcom/features/bookings/lib/handlePayment";
|
||||
import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";
|
||||
import { isEventTypeLoggingEnabled } from "@calcom/features/bookings/lib/isEventTypeLoggingEnabled";
|
||||
import { BookingEventHandlerService } from "@calcom/features/bookings/lib/onBookingEvents/BookingEventHandlerService";
|
||||
import type { CacheService } from "@calcom/features/calendar-cache/lib/getShouldServeCache";
|
||||
import { getSpamCheckService } from "@calcom/features/di/watchlist/containers/SpamCheckService.container";
|
||||
import { getBookerBaseUrl } from "@calcom/features/ee/organizations/lib/getBookerUrlServer";
|
||||
@@ -42,7 +43,7 @@ import { WorkflowRepository } from "@calcom/features/ee/workflows/repositories/W
|
||||
import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents";
|
||||
import { getEventName, updateHostInEventName } from "@calcom/features/eventtypes/lib/eventNaming";
|
||||
import { getFullName } from "@calcom/features/form-builder/utils";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/services/hashedLinkService";
|
||||
import type { HashedLinkService } from "@calcom/features/hashedLink/lib/service/HashedLinkService";
|
||||
import { ProfileRepository } from "@calcom/features/profile/repositories/ProfileRepository";
|
||||
import { handleAnalyticsEvents } from "@calcom/features/tasker/tasks/analytics/handleAnalyticsEvents";
|
||||
import type { UserRepository } from "@calcom/features/users/repositories/UserRepository";
|
||||
@@ -416,6 +417,7 @@ export interface IBookingServiceDependencies {
|
||||
bookingRepository: BookingRepository;
|
||||
luckyUserService: LuckyUserService;
|
||||
userRepository: UserRepository;
|
||||
hashedLinkService: HashedLinkService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2231,6 +2233,33 @@ async function handler(
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const bookingFlowConfig = {
|
||||
isDryRun,
|
||||
};
|
||||
|
||||
const bookingCreatedPayload = {
|
||||
config: bookingFlowConfig,
|
||||
bookingFormData: {
|
||||
// FIXME: It looks like hasHashedBookingLink is set to true based on the value of hashedLink when sending the request. So, technically we could remove hasHashedBookingLink usage completely
|
||||
hashedLink: hasHashedBookingLink ? reqBody.hashedLink ?? null : null,
|
||||
},
|
||||
};
|
||||
|
||||
// Add more fields here when needed
|
||||
const bookingRescheduledPayload = bookingCreatedPayload;
|
||||
|
||||
const bookingEventHandler = new BookingEventHandlerService({
|
||||
log: loggerWithEventDetails,
|
||||
hashedLinkService: deps.hashedLinkService,
|
||||
});
|
||||
|
||||
// TODO: Incrementally move all stuff that happens after a booking is created to these handlers
|
||||
if (originalRescheduledBooking) {
|
||||
await bookingEventHandler.onBookingRescheduled(bookingRescheduledPayload);
|
||||
} else {
|
||||
await bookingEventHandler.onBookingCreated(bookingCreatedPayload);
|
||||
}
|
||||
|
||||
const webhookData: EventPayloadType = {
|
||||
...evt,
|
||||
...eventTypeInfo,
|
||||
@@ -2468,23 +2497,6 @@ async function handler(
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const hashedLinkService = new HashedLinkService();
|
||||
if (hasHashedBookingLink && reqBody.hashedLink && !isDryRun) {
|
||||
await hashedLinkService.validateAndIncrementUsage(reqBody.hashedLink as string);
|
||||
}
|
||||
} catch (error) {
|
||||
loggerWithEventDetails.error("Error while updating hashed link", JSON.stringify({ error }));
|
||||
|
||||
// Handle repository errors and convert to HttpErrors
|
||||
if (error instanceof Error) {
|
||||
throw new HttpError({ statusCode: 410, message: error.message });
|
||||
}
|
||||
|
||||
// For unexpected errors, provide a generic message
|
||||
throw new HttpError({ statusCode: 500, message: "Failed to process booking link" });
|
||||
}
|
||||
|
||||
if (!booking) throw new HttpError({ statusCode: 400, message: "Booking failed" });
|
||||
|
||||
try {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
import { redisModule } from "@calcom/features/redis/di/redisModule";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
import type { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
|
||||
import { membershipRepositoryModule } from "@calcom/features/users/di/MembershipRepository.module";
|
||||
import { createContainer } from "../di";
|
||||
import { availableSlotsModule } from "../modules/AvailableSlots";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
@@ -13,7 +13,6 @@ import { eventTypeRepositoryModule } from "../modules/EventType";
|
||||
import { featuresRepositoryModule } from "../modules/Features";
|
||||
import { filterHostsModule } from "../modules/FilterHosts";
|
||||
import { getUserAvailabilityModule } from "../modules/GetUserAvailability";
|
||||
import { membershipRepositoryModule } from "../modules/Membership";
|
||||
import { noSlotsNotificationModule } from "../modules/NoSlotsNotification";
|
||||
import { oooRepositoryModule } from "../modules/Ooo";
|
||||
import { qualifiedHostsModule } from "../modules/QualifiedHosts";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
import { redisModule } from "@calcom/features/redis/di/redisModule";
|
||||
import { membershipRepositoryModule } from "@calcom/features/users/di/MembershipRepository.module";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
import type { NoSlotsNotificationService } from "@calcom/trpc/server/routers/viewer/slots/handleNotificationWhenNoSlots";
|
||||
|
||||
import { createContainer } from "../di";
|
||||
import { membershipRepositoryModule } from "../modules/Membership";
|
||||
import { noSlotsNotificationModule } from "../modules/NoSlotsNotification";
|
||||
import { teamRepositoryModule } from "../modules/Team";
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
import { MembershipRepository } from "@calcom/features/membership/repositories/MembershipRepository";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const membershipRepositoryModule = createModule();
|
||||
membershipRepositoryModule
|
||||
.bind(DI_TOKENS.MEMBERSHIP_REPOSITORY)
|
||||
.toClass(MembershipRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BOOKING_DI_TOKENS } from "@calcom/features/bookings/di/tokens";
|
||||
import { HASHED_LINK_DI_TOKENS } from "@calcom/features/hashedLink/di/tokens";
|
||||
|
||||
import { WATCHLIST_DI_TOKENS } from "./watchlist/Watchlist.tokens";
|
||||
|
||||
@@ -55,7 +56,11 @@ export const DI_TOKENS = {
|
||||
HOST_REPOSITORY_MODULE: Symbol("HostRepositoryModule"),
|
||||
ATTRIBUTE_REPOSITORY: Symbol("AttributeRepository"),
|
||||
ATTRIBUTE_REPOSITORY_MODULE: Symbol("AttributeRepositoryModule"),
|
||||
MEMBERSHIP_SERVICE: Symbol("MembershipService"),
|
||||
MEMBERSHIP_SERVICE_MODULE: Symbol("MembershipServiceModule"),
|
||||
// Booking service tokens
|
||||
...BOOKING_DI_TOKENS,
|
||||
...HASHED_LINK_DI_TOKENS,
|
||||
// Watchlist service tokens
|
||||
...WATCHLIST_DI_TOKENS,
|
||||
};
|
||||
@@ -1,8 +1,13 @@
|
||||
import { WorkflowActions, WorkflowTriggerEvents } from "@calcom/prisma/enums";
|
||||
|
||||
import type { Workflow } from "./types";
|
||||
type WorkflowWithStepsAndTrigger = {
|
||||
trigger: WorkflowTriggerEvents;
|
||||
steps: {
|
||||
action: WorkflowActions;
|
||||
}[];
|
||||
};
|
||||
|
||||
export function allowDisablingHostConfirmationEmails(workflows: Workflow[]) {
|
||||
export function allowDisablingHostConfirmationEmails(workflows: WorkflowWithStepsAndTrigger[]) {
|
||||
return !!workflows.find(
|
||||
(workflow) =>
|
||||
workflow.trigger === WorkflowTriggerEvents.NEW_EVENT &&
|
||||
@@ -10,7 +15,7 @@ export function allowDisablingHostConfirmationEmails(workflows: Workflow[]) {
|
||||
);
|
||||
}
|
||||
|
||||
export function allowDisablingAttendeeConfirmationEmails(workflows: Workflow[]) {
|
||||
export function allowDisablingAttendeeConfirmationEmails(workflows: WorkflowWithStepsAndTrigger[]) {
|
||||
return !!workflows.find(
|
||||
(workflow) =>
|
||||
workflow.trigger === WorkflowTriggerEvents.NEW_EVENT &&
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { bindModuleToClassOnToken, createModule, type ModuleLoader } from "@calcom/features/di/di";
|
||||
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
import { moduleLoader as prismaModuleLoader } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import { HashedLinkRepository } from "../lib/repository/HashedLinkRepository";
|
||||
|
||||
const thisModule = createModule();
|
||||
const token = DI_TOKENS.HASHED_LINK_REPOSITORY;
|
||||
const moduleToken = DI_TOKENS.HASHED_LINK_REPOSITORY_MODULE;
|
||||
const loadModule = bindModuleToClassOnToken({
|
||||
module: thisModule,
|
||||
moduleToken,
|
||||
token,
|
||||
classs: HashedLinkRepository,
|
||||
dep: prismaModuleLoader,
|
||||
});
|
||||
|
||||
export const moduleLoader: ModuleLoader = {
|
||||
token,
|
||||
loadModule,
|
||||
};
|
||||
|
||||
export type { HashedLinkRepository };
|
||||
@@ -0,0 +1,27 @@
|
||||
import { moduleLoader as membershipServiceModuleLoader } from "@calcom/features/users/di/MembershipService.module";
|
||||
import { bindModuleToClassOnToken, createModule } from "@calcom/features/di/di";
|
||||
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
|
||||
import { HashedLinkService } from "../lib/service/HashedLinkService";
|
||||
import { moduleLoader as hashedLinkRepositoryModuleLoader } from "./HashedLinkRepository.module";
|
||||
|
||||
const thisModule = createModule();
|
||||
const token = DI_TOKENS.HASHED_LINK_SERVICE;
|
||||
const moduleToken = DI_TOKENS.HASHED_LINK_SERVICE_MODULE;
|
||||
const loadModule = bindModuleToClassOnToken({
|
||||
module: thisModule,
|
||||
moduleToken,
|
||||
token,
|
||||
classs: HashedLinkService,
|
||||
depsMap: {
|
||||
hashedLinkRepository: hashedLinkRepositoryModuleLoader,
|
||||
membershipService: membershipServiceModuleLoader,
|
||||
},
|
||||
});
|
||||
|
||||
export const moduleLoader = {
|
||||
token,
|
||||
loadModule,
|
||||
};
|
||||
|
||||
export type { HashedLinkService };
|
||||
@@ -0,0 +1,6 @@
|
||||
export const HASHED_LINK_DI_TOKENS = {
|
||||
HASHED_LINK_REPOSITORY: Symbol("HashedLinkRepository"),
|
||||
HASHED_LINK_REPOSITORY_MODULE: Symbol("HashedLinkRepositoryModule"),
|
||||
HASHED_LINK_SERVICE: Symbol("HashedLinkService"),
|
||||
HASHED_LINK_SERVICE_MODULE: Symbol("HashedLinkServiceModule"),
|
||||
};
|
||||
File renamed without changes.
+23
-13
@@ -1,10 +1,11 @@
|
||||
import {
|
||||
HashedLinkRepository,
|
||||
type HashedLinkInputType,
|
||||
} from "@calcom/features/hashedLink/repositories/hashedLinkRepository";
|
||||
import { MembershipService } from "@calcom/features/membership/services/membershipService";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { validateHashedLinkData } from "@calcom/lib/hashedLinksUtils";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
|
||||
import { HashedLinkRepository } from "../repository/HashedLinkRepository";
|
||||
import { type HashedLinkInputType } from "../repository/HashedLinkRepository";
|
||||
|
||||
type NormalizedLink = {
|
||||
link: string;
|
||||
@@ -12,11 +13,19 @@ type NormalizedLink = {
|
||||
maxUsageCount?: number | null;
|
||||
};
|
||||
|
||||
interface HashedLinkServiceDeps {
|
||||
hashedLinkRepository: HashedLinkRepository;
|
||||
membershipService: MembershipService;
|
||||
}
|
||||
|
||||
export class HashedLinkService {
|
||||
constructor(
|
||||
private readonly hashedLinkRepository: HashedLinkRepository = HashedLinkRepository.create(),
|
||||
private readonly membershipService: MembershipService = new MembershipService()
|
||||
) {}
|
||||
private readonly hashedLinkRepository: HashedLinkRepository;
|
||||
private readonly membershipService: MembershipService;
|
||||
|
||||
constructor(deps?: HashedLinkServiceDeps) {
|
||||
this.hashedLinkRepository = deps?.hashedLinkRepository ?? HashedLinkRepository.create();
|
||||
this.membershipService = deps?.membershipService ?? new MembershipService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes link input to a consistent format
|
||||
@@ -27,10 +36,10 @@ export class HashedLinkService {
|
||||
return typeof input === "string"
|
||||
? { link: input, expiresAt: null }
|
||||
: {
|
||||
link: input.link,
|
||||
expiresAt: input.expiresAt ?? null,
|
||||
maxUsageCount: input.maxUsageCount,
|
||||
};
|
||||
link: input.link,
|
||||
expiresAt: input.expiresAt ?? null,
|
||||
maxUsageCount: input.maxUsageCount,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +123,8 @@ export class HashedLinkService {
|
||||
if (hashedLink.maxUsageCount && hashedLink.maxUsageCount > 0) {
|
||||
try {
|
||||
await this.hashedLinkRepository.incrementUsage(hashedLink.id, hashedLink.maxUsageCount);
|
||||
} catch (updateError) {
|
||||
} catch (e) {
|
||||
logger.error("Error incrementing usage for hashed link", safeStringify(e));
|
||||
throw new Error(ErrorCode.PrivateLinkExpired);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { bindModuleToClassOnToken, createModule, type ModuleLoader } from "@calcom/features/di/di";
|
||||
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
import { MembershipRepository } from "@calcom/features/membership/repositories/MembershipRepository";
|
||||
import { moduleLoader as prismaModuleLoader } from "@calcom/prisma/prisma.module";
|
||||
|
||||
export const membershipRepositoryModule = createModule();
|
||||
const token = DI_TOKENS.MEMBERSHIP_REPOSITORY;
|
||||
const moduleToken = DI_TOKENS.MEMBERSHIP_REPOSITORY_MODULE;
|
||||
const loadModule = bindModuleToClassOnToken({
|
||||
module: membershipRepositoryModule,
|
||||
moduleToken,
|
||||
token,
|
||||
classs: MembershipRepository,
|
||||
dep: prismaModuleLoader,
|
||||
});
|
||||
|
||||
export const moduleLoader: ModuleLoader = {
|
||||
token,
|
||||
loadModule,
|
||||
};
|
||||
|
||||
export type { MembershipRepository };
|
||||
@@ -0,0 +1,25 @@
|
||||
import { bindModuleToClassOnToken, createModule, type ModuleLoader } from "@calcom/features/di/di";
|
||||
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
||||
import { MembershipService } from "@calcom/features/membership/services/membershipService";
|
||||
|
||||
import { moduleLoader as membershipRepositoryModuleLoader } from "./MembershipRepository.module";
|
||||
|
||||
const thisModule = createModule();
|
||||
const token = DI_TOKENS.MEMBERSHIP_SERVICE;
|
||||
const moduleToken = DI_TOKENS.MEMBERSHIP_SERVICE_MODULE;
|
||||
const loadModule = bindModuleToClassOnToken({
|
||||
module: thisModule,
|
||||
moduleToken,
|
||||
token,
|
||||
classs: MembershipService,
|
||||
depsMap: {
|
||||
membershipRepository: membershipRepositoryModuleLoader,
|
||||
},
|
||||
});
|
||||
|
||||
export const moduleLoader: ModuleLoader = {
|
||||
token,
|
||||
loadModule,
|
||||
};
|
||||
|
||||
export type { MembershipService };
|
||||
@@ -1,2 +1,3 @@
|
||||
export { generateHashedLink } from "@calcom/lib/generateHashedLink";
|
||||
export { isLinkExpired } from "@calcom/lib/hashedLinksUtils";
|
||||
export { HashedLinkService } from "@calcom/features/hashedLink/lib/service/HashedLinkService";
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HashedLinkRepository } from "@calcom/features/hashedLink/repositories/hashedLinkRepository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/services/hashedLinkService";
|
||||
import { HashedLinkRepository } from "@calcom/features/hashedLink/lib/repository/HashedLinkRepository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/lib/service/HashedLinkService";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HashedLinkRepository } from "@calcom/features/hashedLink/repositories/hashedLinkRepository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/services/hashedLinkService";
|
||||
import { HashedLinkRepository } from "@calcom/features/hashedLink/lib/repository/HashedLinkRepository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/lib/service/HashedLinkService";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import {
|
||||
allowDisablingAttendeeConfirmationEmails,
|
||||
allowDisablingHostConfirmationEmails,
|
||||
} from "@calcom/features/ee/workflows/lib/allowDisablingStandardEmails";
|
||||
import { HashedLinkRepository } from "@calcom/features/hashedLink/repositories/hashedLinkRepository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/services/hashedLinkService";
|
||||
import { HashedLinkRepository } from "@calcom/features/hashedLink/lib/repository/HashedLinkRepository";
|
||||
import { HashedLinkService } from "@calcom/features/hashedLink/lib/service/HashedLinkService";
|
||||
import { MembershipRepository } from "@calcom/features/membership/repositories/MembershipRepository";
|
||||
import tasker from "@calcom/features/tasker";
|
||||
import { validateIntervalLimitOrder } from "@calcom/lib/intervalLimits/validateIntervalLimitOrder";
|
||||
@@ -523,7 +523,11 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
trigger: WorkflowTriggerEvents.NEW_EVENT,
|
||||
},
|
||||
include: {
|
||||
steps: true,
|
||||
steps: {
|
||||
select: {
|
||||
action: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -630,7 +634,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
const isCalVideoLocationActive = locations
|
||||
? locations.some((location) => location.type === DailyLocationType)
|
||||
: parsedEventTypeLocations.success &&
|
||||
parsedEventTypeLocations.data?.some((location) => location.type === DailyLocationType);
|
||||
parsedEventTypeLocations.data?.some((location) => location.type === DailyLocationType);
|
||||
|
||||
if (eventType.calVideoSettings && !isCalVideoLocationActive) {
|
||||
await CalVideoSettingsRepository.deleteCalVideoSettings(id);
|
||||
|
||||
Reference in new issue
Block a user