fix: Slots are available even after exceeding the booking limits for the team event (#21801)
* fix: slots available * fix type error * update * update
This commit is contained in:
@@ -58,6 +58,17 @@ export default class LimitManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges busy times from another LimitManager
|
||||
*/
|
||||
mergeBusyTimes(otherManager: LimitManager) {
|
||||
otherManager.busyMap.forEach((busyTime, key) => {
|
||||
if (!this.busyMap.has(key)) {
|
||||
this.busyMap.set(key, busyTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all busy times
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ import { parseBookingLimit } from "@calcom/lib/intervalLimits/isBookingLimits";
|
||||
import { parseDurationLimit } from "@calcom/lib/intervalLimits/isDurationLimits";
|
||||
import LimitManager from "@calcom/lib/intervalLimits/limitManager";
|
||||
import { checkBookingLimit } from "@calcom/lib/intervalLimits/server/checkBookingLimits";
|
||||
import { getUnitFromBusyTime, isBookingWithinPeriod } from "@calcom/lib/intervalLimits/utils";
|
||||
import { isBookingWithinPeriod } from "@calcom/lib/intervalLimits/utils";
|
||||
import {
|
||||
calculatePeriodLimits,
|
||||
isTimeOutOfBounds,
|
||||
@@ -1031,13 +1031,7 @@ const _getBusyTimesFromLimitsForUsers = async (
|
||||
const userBookings = busyTimesFromLimitsBookings.filter((booking) => booking.userId === user.id);
|
||||
const limitManager = new LimitManager();
|
||||
|
||||
for (const busyTime of globalLimitManager.getBusyTimes()) {
|
||||
const start = dayjs(busyTime.start);
|
||||
const end = dayjs(busyTime.end);
|
||||
const unit = getUnitFromBusyTime(start, end);
|
||||
|
||||
limitManager.addBusyTime(start, unit, timeZone);
|
||||
}
|
||||
limitManager.mergeBusyTimes(globalLimitManager);
|
||||
|
||||
if (bookingLimits) {
|
||||
for (const key of descendingLimitKeys) {
|
||||
@@ -1222,13 +1216,8 @@ const _getBusyTimesFromTeamLimitsForUsers = async (
|
||||
const userBusyTimes = busyTimes.filter((busyTime) => busyTime.userId === user.id);
|
||||
const limitManager = new LimitManager();
|
||||
|
||||
for (const busyTime of globalLimitManager.getBusyTimes()) {
|
||||
const start = dayjs(busyTime.start);
|
||||
const end = dayjs(busyTime.end);
|
||||
const unit = getUnitFromBusyTime(start, end);
|
||||
limitManager.mergeBusyTimes(globalLimitManager);
|
||||
|
||||
limitManager.addBusyTime(start, unit, timeZone);
|
||||
}
|
||||
const bookingLimitsParams = {
|
||||
bookings: userBusyTimes,
|
||||
bookingLimits,
|
||||
|
||||
Reference in New Issue
Block a user