[CAL-988] Limit total appointment time per day/week/month/year (#7166)

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-03-10 21:00:19 +01:00
1 parent eb66931366
commit cbc9cd60d5
28 files changed
+664 -228

No files matched your search

@@ -43,7 +43,7 @@ import { HttpError } from "@calcom/lib/http-error";
import isOutOfBounds, { BookingDateInPastError } from "@calcom/lib/isOutOfBounds";
import logger from "@calcom/lib/logger";
import { handlePayment } from "@calcom/lib/payment/handlePayment";
import { checkBookingLimits, getLuckyUser } from "@calcom/lib/server";
import { checkBookingLimits, checkDurationLimits, getLuckyUser } from "@calcom/lib/server";
import { getTranslation } from "@calcom/lib/server/i18n";
import { slugify } from "@calcom/lib/slugify";
import { updateWebUser as syncServicesUpdateWebUser } from "@calcom/lib/sync/SyncServiceManager";
@@ -222,6 +222,7 @@ const getEventTypesFromDB = async (eventTypeId: number) => {
recurringEvent: true,
seatsShowAttendees: true,
bookingLimits: true,
durationLimits: true,
workflows: {
include: {
workflow: {
@@ -592,6 +593,11 @@ async function handler(
await checkBookingLimits(eventType.bookingLimits, startAsDate, eventType.id);
}
if (eventType && eventType.hasOwnProperty("durationLimits") && eventType?.durationLimits) {
const startAsDate = dayjs(reqBody.start).toDate();
await checkDurationLimits(eventType.durationLimits, startAsDate, eventType.id);
}
if (!eventType.seatsPerTimeSlot) {
const availableUsers = await ensureAvailableUsers(
{