Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee1904bb2c | ||
|
|
aaa59f1455 | ||
|
|
e29b7e83b8 | ||
|
|
6af473a486 | ||
|
|
bf8f966811 | ||
|
|
c64b663514 | ||
|
|
29314cde75 | ||
|
|
3ea73e75d6 | ||
|
|
d18e23378b | ||
|
|
736f1f594c | ||
|
|
09b1643478 | ||
|
|
86f6e8bac3 | ||
|
|
9c65d02e84 | ||
|
|
be9ab02a7e | ||
|
|
cfefba6d4d | ||
|
|
815e13303b | ||
|
|
7c8dbb3ea3 | ||
|
|
cabd459682 | ||
|
|
33aedbae20 | ||
|
|
d3fbc73a39 | ||
|
|
cfda4757e4 | ||
|
|
895ed48bd6 | ||
|
|
eda328d196 | ||
|
|
1c501d1501 | ||
|
|
08a57f32c5 | ||
|
|
b5a26bc227 | ||
|
|
737b019199 | ||
|
|
b41031626f | ||
|
|
a1fc4bccb9 | ||
|
|
d764b6a32d | ||
|
|
87cb8b170a | ||
|
|
badd0de33c | ||
|
|
124fd8ebca | ||
|
|
5d0dc3f546 | ||
|
|
e4baf15b53 | ||
|
|
a1bd8b6259 | ||
|
|
7987c9f45d | ||
|
|
781d0d92df | ||
|
|
b71d8baccc | ||
|
|
a71d949a0c | ||
|
|
e55cee443b | ||
|
|
c3634b3aba | ||
|
|
cd576f5378 | ||
|
|
2965450929 | ||
|
|
db9b9c45dc | ||
|
|
37f500526c | ||
|
|
006aecb066 | ||
|
|
0829929e98 | ||
|
|
a61148cb51 | ||
|
|
593c48c8b4 | ||
|
|
fb364971fa | ||
|
|
a2205d497d | ||
|
|
cf4e7a5d2c | ||
|
|
0e2ee3adb2 | ||
|
|
dbe8a85cf5 | ||
|
|
84210dc1b4 | ||
|
|
4061bfb3fe | ||
|
|
18059e50fa | ||
|
|
852eb346ed | ||
|
|
b7e11dc112 | ||
|
|
35a373e70a | ||
|
|
02c0b721b9 | ||
|
|
29349845f8 | ||
|
|
28cb2cff64 | ||
|
|
9cb2eb3b8c | ||
|
|
6ff20b98f4 | ||
|
|
aa618dbaa2 |
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@calcom/atoms": patch
|
||||
---
|
||||
|
||||
Added new startTime prop to the Booker component that allows users to decide the first available date when the booker loads
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"@calcom/atoms": minor
|
||||
---
|
||||
|
||||
Added new callback functions to the handleFormSubmit method in the EventTypeSettings and AvailabilitySettings atoms. The handleFormSubmit method now accepts an optional callbacks object with the following properties:
|
||||
|
||||
- **onSuccess**: Called when the form submission is successful, allowing additional logic to be executed after the update.
|
||||
|
||||
- **onError**: Called when an error occurs during form submission, providing details about the error to handle specific cases or display custom messages.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@calcom/atoms": minor
|
||||
---
|
||||
|
||||
booker atom: allow toggling org and team info when booking round robin
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
"@calcom/atoms": patch
|
||||
---
|
||||
|
||||
This change fixes an issue in the CalendarSettings atom where the redirect urls were getting only one search param
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@calcom/atoms": patch
|
||||
---
|
||||
|
||||
This change fixes date overrides breaking for availability settings atom
|
||||
+5
-1
@@ -1 +1,5 @@
|
||||
module.exports = require("./packages/config/eslint-preset");
|
||||
// This configuration only applies to the package manager root.
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
extends: ["./packages/config/eslint-preset.js"],
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@ env:
|
||||
STRIPE_API_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }}
|
||||
STRIPE_CLIENT_ID: ${{ secrets.CI_STRIPE_CLIENT_ID }}
|
||||
STRIPE_WEBHOOK_SECRET: ${{ secrets.CI_STRIPE_WEBHOOK_SECRET }}
|
||||
SLOTS_CACHE_TTL: ${{ secrets.CI_SLOTS_CACHE_TTL }}
|
||||
jobs:
|
||||
e2e:
|
||||
timeout-minutes: 20
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
undecided:
|
||||
- "@calcom/prisma"
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
undecided:
|
||||
- "@calcom/prisma"
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
undecided:
|
||||
- "@calcom/prisma"
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
undecided:
|
||||
- "@calcom/prisma"
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
undecided:
|
||||
- "@calcom/prisma"
|
||||
@@ -38,7 +38,7 @@
|
||||
"next-axiom": "^0.17.0",
|
||||
"next-swagger-doc": "^0.3.6",
|
||||
"next-validations": "^0.2.0",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript": "^5.9.0-beta",
|
||||
"tzdata": "^1.0.30",
|
||||
"uuid": "^8.3.2",
|
||||
"zod": "^3.22.4"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { NextApiRequest } from "next";
|
||||
import { z } from "zod";
|
||||
|
||||
import { getUserAvailability } from "@calcom/lib/getUserAvailability";
|
||||
import { getUserAvailabilityService } from "@calcom/lib/di/containers/get-user-availability";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
|
||||
import prisma from "@calcom/prisma";
|
||||
@@ -191,8 +191,9 @@ const availabilitySchema = z
|
||||
async function handler(req: NextApiRequest) {
|
||||
const { isSystemWideAdmin, userId: reqUserId } = req;
|
||||
const { username, userId, eventTypeId, dateTo, dateFrom, teamId } = availabilitySchema.parse(req.query);
|
||||
const userAvailabilityService = getUserAvailabilityService();
|
||||
if (!teamId)
|
||||
return getUserAvailability({
|
||||
return userAvailabilityService.getUserAvailability({
|
||||
username,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
@@ -230,7 +231,7 @@ async function handler(req: NextApiRequest) {
|
||||
const availabilities = members.map(async (user) => {
|
||||
return {
|
||||
userId: user.id,
|
||||
availability: await getUserAvailability({
|
||||
availability: await userAvailabilityService.getUserAvailability({
|
||||
userId: user.id,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
|
||||
@@ -42,15 +42,17 @@ $ yarn prisma generate
|
||||
|
||||
Copy `.env.example` to `.env` and fill values.
|
||||
|
||||
## Add license Key to deployments table in DB
|
||||
## Add license Key to Deployment table in DB
|
||||
|
||||
id, logo theme licenseKey agreedLicenseAt
|
||||
1, null, null, 'c4234812-12ab-42s6-a1e3-55bedd4a5bb7', '2023-05-15 21:39:47.611'
|
||||
id, logo, theme, licenseKey, agreedLicenseAt:-
|
||||
1, null, null, '00000000-0000-0000-0000-000000000000', '2023-05-15 21:39:47.611'
|
||||
|
||||
Replace with your actual license key.
|
||||
|
||||
your CALCOM_LICENSE_KEY env var need to contain the same value
|
||||
|
||||
.env
|
||||
CALCOM_LICENSE_KEY=c4234812-12ab-42s6-a1e3-55bedd4a5bb
|
||||
CALCOM_LICENSE_KEY=00000000-0000-0000-0000-000000000000
|
||||
|
||||
## Running the app
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"@axiomhq/winston": "^1.2.0",
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-enums": "*",
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.276",
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.291",
|
||||
"@calcom/platform-types": "*",
|
||||
"@calcom/platform-utils": "*",
|
||||
"@calcom/prisma": "*",
|
||||
@@ -98,6 +98,8 @@
|
||||
"@types/luxon": "^3.3.7",
|
||||
"@types/passport-jwt": "^3.0.13",
|
||||
"@types/supertest": "^2.0.12",
|
||||
"@typescript-eslint/eslint-plugin": "^6",
|
||||
"@typescript-eslint/parser": "^6",
|
||||
"jest": "^29.7.0",
|
||||
"jest-date-mock": "^1.0.10",
|
||||
"node-mocks-http": "^1.16.2",
|
||||
@@ -108,7 +110,7 @@
|
||||
"ts-loader": "^9.4.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths": "^4.1.0",
|
||||
"typescript": "^5.7.2"
|
||||
"typescript": "^5.9.0-beta"
|
||||
},
|
||||
"prisma": {
|
||||
"schema": "../../../packages/prisma/schema.prisma"
|
||||
|
||||
@@ -104,10 +104,11 @@ export class OutputBookingsService_2024_08_13 {
|
||||
const rescheduledToInfo = databaseBooking.rescheduled
|
||||
? await this.getRescheduledToInfo(databaseBooking.uid)
|
||||
: undefined;
|
||||
|
||||
const rescheduledToUid = rescheduledToInfo?.uid;
|
||||
const rescheduledByEmail = databaseBooking.rescheduled ? rescheduledToInfo?.rescheduledBy : databaseBooking.rescheduledBy;
|
||||
|
||||
const rescheduledToUid = rescheduledToInfo?.uid;
|
||||
const rescheduledByEmail = databaseBooking.rescheduled
|
||||
? rescheduledToInfo?.rescheduledBy
|
||||
: databaseBooking.rescheduledBy;
|
||||
|
||||
const booking = {
|
||||
id: databaseBooking.id,
|
||||
@@ -157,13 +158,12 @@ export class OutputBookingsService_2024_08_13 {
|
||||
|
||||
async getRescheduledToInfo(bookingUid: string): Promise<{ uid?: string; rescheduledBy?: string | null }> {
|
||||
const rescheduledTo = await this.bookingsRepository.getByFromReschedule(bookingUid);
|
||||
return {
|
||||
uid: rescheduledTo?.uid,
|
||||
rescheduledBy: rescheduledTo?.rescheduledBy
|
||||
return {
|
||||
uid: rescheduledTo?.uid,
|
||||
rescheduledBy: rescheduledTo?.rescheduledBy,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getUserDefinedMetadata(databaseMetadata: DatabaseMetadata) {
|
||||
if (databaseMetadata === null) return {};
|
||||
|
||||
@@ -279,9 +279,11 @@ export class OutputBookingsService_2024_08_13 {
|
||||
const rescheduledToInfo = databaseBooking.rescheduled
|
||||
? await this.getRescheduledToInfo(databaseBooking.uid)
|
||||
: undefined;
|
||||
|
||||
|
||||
const rescheduledToUid = rescheduledToInfo?.uid;
|
||||
const rescheduledByEmail = databaseBooking.rescheduled ? rescheduledToInfo?.rescheduledBy : databaseBooking.rescheduledBy;
|
||||
const rescheduledByEmail = databaseBooking.rescheduled
|
||||
? rescheduledToInfo?.rescheduledBy
|
||||
: databaseBooking.rescheduledBy;
|
||||
|
||||
const booking = {
|
||||
id: databaseBooking.id,
|
||||
|
||||
+4
-1
@@ -290,7 +290,10 @@ describe("Event types Endpoints", () => {
|
||||
expect(responseBookingFields).toBeDefined();
|
||||
// note(Lauris): response bookingFields are already existing default bookingFields + the new one
|
||||
const responseBookingField = responseBookingFields.find((field) => field.name === bookingFieldName);
|
||||
expect(responseBookingField).toEqual(bookingFields[0]);
|
||||
const fields = responseBookingField
|
||||
//@ts-ignore
|
||||
delete fields.labelAsSafeHtml
|
||||
expect(fields).toEqual(bookingFields[0]);
|
||||
eventType.bookingFields = responseBookingFields;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,9 +8,12 @@ import { PrismaSelectedSlotRepository } from "@/lib/repositories/prisma-selected
|
||||
import { PrismaTeamRepository } from "@/lib/repositories/prisma-team.repository";
|
||||
import { PrismaUserRepository } from "@/lib/repositories/prisma-user.repository";
|
||||
import { AvailableSlotsService } from "@/lib/services/available-slots.service";
|
||||
import { BusyTimesService } from "@/lib/services/busy-times.service";
|
||||
import { CacheService } from "@/lib/services/cache.service";
|
||||
import { CheckBookingLimitsService } from "@/lib/services/check-booking-limits.service";
|
||||
import { UserAvailabilityService } from "@/lib/services/user-availability.service";
|
||||
import { PrismaModule } from "@/modules/prisma/prisma.module";
|
||||
import { RedisService } from "@/modules/redis/redis.service";
|
||||
import { Module } from "@nestjs/common";
|
||||
|
||||
@Module({
|
||||
@@ -24,10 +27,13 @@ import { Module } from "@nestjs/common";
|
||||
PrismaEventTypeRepository,
|
||||
PrismaRoutingFormResponseRepository,
|
||||
PrismaTeamRepository,
|
||||
RedisService,
|
||||
PrismaFeaturesRepository,
|
||||
CheckBookingLimitsService,
|
||||
CacheService,
|
||||
AvailableSlotsService,
|
||||
UserAvailabilityService,
|
||||
BusyTimesService,
|
||||
],
|
||||
exports: [AvailableSlotsService],
|
||||
})
|
||||
|
||||
@@ -7,12 +7,16 @@ import { PrismaScheduleRepository } from "@/lib/repositories/prisma-schedule.rep
|
||||
import { PrismaSelectedSlotRepository } from "@/lib/repositories/prisma-selected-slot.repository";
|
||||
import { PrismaTeamRepository } from "@/lib/repositories/prisma-team.repository";
|
||||
import { PrismaUserRepository } from "@/lib/repositories/prisma-user.repository";
|
||||
import { BusyTimesService } from "@/lib/services/busy-times.service";
|
||||
import { CacheService } from "@/lib/services/cache.service";
|
||||
import { CheckBookingLimitsService } from "@/lib/services/check-booking-limits.service";
|
||||
import { RedisService } from "@/modules/redis/redis.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { AvailableSlotsService as BaseAvailableSlotsService } from "@calcom/platform-libraries/slots";
|
||||
|
||||
import { UserAvailabilityService } from "./user-availability.service";
|
||||
|
||||
@Injectable()
|
||||
export class AvailableSlotsService extends BaseAvailableSlotsService {
|
||||
constructor(
|
||||
@@ -24,6 +28,7 @@ export class AvailableSlotsService extends BaseAvailableSlotsService {
|
||||
selectedSlotRepository: PrismaSelectedSlotRepository,
|
||||
eventTypeRepository: PrismaEventTypeRepository,
|
||||
userRepository: PrismaUserRepository,
|
||||
redisService: RedisService,
|
||||
featuresRepository: PrismaFeaturesRepository
|
||||
) {
|
||||
super({
|
||||
@@ -35,8 +40,16 @@ export class AvailableSlotsService extends BaseAvailableSlotsService {
|
||||
selectedSlotRepo: selectedSlotRepository,
|
||||
eventTypeRepo: eventTypeRepository,
|
||||
userRepo: userRepository,
|
||||
checkBookingLimitsService: new CheckBookingLimitsService(bookingRepository) as any,
|
||||
redisClient: redisService,
|
||||
checkBookingLimitsService: new CheckBookingLimitsService(bookingRepository),
|
||||
cacheService: new CacheService(featuresRepository),
|
||||
userAvailabilityService: new UserAvailabilityService(
|
||||
oooRepoDependency,
|
||||
bookingRepository,
|
||||
eventTypeRepository,
|
||||
redisService
|
||||
),
|
||||
busyTimesService: new BusyTimesService(bookingRepository),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { PrismaBookingRepository } from "@/lib/repositories/prisma-booking.repository";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { BusyTimesService as BaseBusyTimesService } from "@calcom/platform-libraries/slots";
|
||||
|
||||
@Injectable()
|
||||
export class BusyTimesService extends BaseBusyTimesService {
|
||||
constructor(bookingRepository: PrismaBookingRepository) {
|
||||
super({
|
||||
bookingRepo: bookingRepository,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { PrismaBookingRepository } from "@/lib/repositories/prisma-booking.repository";
|
||||
import { PrismaEventTypeRepository } from "@/lib/repositories/prisma-event-type.repository";
|
||||
import { PrismaOOORepository } from "@/lib/repositories/prisma-ooo.repository";
|
||||
import { RedisService } from "@/modules/redis/redis.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { UserAvailabilityService as BaseUserAvailabilityService } from "@calcom/platform-libraries/schedules";
|
||||
|
||||
@Injectable()
|
||||
export class UserAvailabilityService extends BaseUserAvailabilityService {
|
||||
constructor(
|
||||
oooRepoDependency: PrismaOOORepository,
|
||||
bookingRepository: PrismaBookingRepository,
|
||||
eventTypeRepository: PrismaEventTypeRepository,
|
||||
redisService: RedisService
|
||||
) {
|
||||
super({
|
||||
oooRepo: oooRepoDependency,
|
||||
bookingRepo: bookingRepository,
|
||||
eventTypeRepo: eventTypeRepository,
|
||||
redisClient: redisService,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -403,6 +403,10 @@ export class BillingService implements OnModuleDestroy {
|
||||
fromReschedule?: string | null;
|
||||
}
|
||||
) {
|
||||
|
||||
if (this.configService.get("e2e")) {
|
||||
return true;
|
||||
}
|
||||
const { uid, startTime, fromReschedule } = booking;
|
||||
|
||||
const delay = startTime.getTime() - Date.now();
|
||||
@@ -427,6 +431,9 @@ export class BillingService implements OnModuleDestroy {
|
||||
* Removing an attendee from a booking does not cancel the usage increment job.
|
||||
*/
|
||||
async cancelUsageByBookingUid(bookingUid: string) {
|
||||
if (this.configService.get("e2e")) {
|
||||
return true;
|
||||
}
|
||||
const job = await this.billingQueue.getJob(`increment-${bookingUid}`);
|
||||
if (job) {
|
||||
await job.remove();
|
||||
@@ -458,6 +465,7 @@ export class BillingService implements OnModuleDestroy {
|
||||
|
||||
async onModuleDestroy() {
|
||||
try {
|
||||
|
||||
await this.billingQueue.close();
|
||||
} catch (err) {
|
||||
this.logger.error(err);
|
||||
|
||||
@@ -7,12 +7,32 @@ import { Redis } from "ioredis";
|
||||
export class RedisService implements OnModuleDestroy {
|
||||
public redis: Redis;
|
||||
private readonly logger = new Logger("RedisService");
|
||||
private isReady = false; // Track connection status
|
||||
|
||||
constructor(readonly configService: ConfigService<AppConfig>) {
|
||||
const dbUrl = configService.get<string>("db.redisUrl", { infer: true });
|
||||
if (!dbUrl) throw new Error("Misconfigured Redis, halting.");
|
||||
|
||||
this.redis = new Redis(dbUrl);
|
||||
|
||||
this.redis.on("error", (err) => {
|
||||
this.logger.error(`IoRedis connection error: ${err.message}`);
|
||||
this.isReady = false;
|
||||
});
|
||||
|
||||
this.redis.on("connect", () => {
|
||||
this.logger.log("IoRedis connected!");
|
||||
this.isReady = true;
|
||||
});
|
||||
|
||||
this.redis.on("reconnecting", (delay: string) => {
|
||||
this.logger.warn(`IoRedis reconnecting... next retry in ${delay}ms`);
|
||||
});
|
||||
|
||||
this.redis.on("end", () => {
|
||||
this.logger.warn("IoRedis connection ended.");
|
||||
this.isReady = false;
|
||||
});
|
||||
}
|
||||
|
||||
async onModuleDestroy() {
|
||||
@@ -22,4 +42,99 @@ export class RedisService implements OnModuleDestroy {
|
||||
this.logger.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
async get<TData>(key: string): Promise<TData | null> {
|
||||
let data = null;
|
||||
if (!this.isReady) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
data = await this.redis.get(key);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) this.logger.error(`IoRedis get failed: ${err.message}`);
|
||||
}
|
||||
|
||||
if (data === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(data) as TData;
|
||||
} catch (e) {
|
||||
return data as TData;
|
||||
}
|
||||
}
|
||||
|
||||
async del(key: string): Promise<number> {
|
||||
if (!this.isReady) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return this.redis.del(key);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) this.logger.error(`IoRedis del failed: ${err.message}`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async set<TData>(key: string, value: TData, opts?: { ttl?: number }): Promise<"OK" | TData | null> {
|
||||
if (!this.isReady) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const stringifiedValue = typeof value === "object" ? JSON.stringify(value) : String(value);
|
||||
if (opts?.ttl) {
|
||||
await this.redis.set(key, stringifiedValue, "PX", opts.ttl);
|
||||
} else {
|
||||
await this.redis.set(key, stringifiedValue);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof Error) this.logger.error(`IoRedis set failed: ${err.message}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
async expire(key: string, seconds: number): Promise<0 | 1> {
|
||||
if (!this.isReady) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return this.redis.expire(key, seconds) as Promise<0 | 1>;
|
||||
} catch (err) {
|
||||
if (err instanceof Error) this.logger.error(`IoRedis expire failed: ${err.message}`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async lrange<TResult = string>(key: string, start: number, end: number): Promise<TResult[]> {
|
||||
if (!this.isReady) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const results = await this.redis.lrange(key, start, end);
|
||||
return results.map((item) => JSON.parse(item) as TResult);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) this.logger.error(`IoRedis lrange failed: ${err.message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async lpush<TData>(key: string, ...elements: TData[]): Promise<number> {
|
||||
if (!this.isReady) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
const stringifiedElements = elements.map((element) =>
|
||||
typeof element === "object" ? JSON.stringify(element) : String(element)
|
||||
);
|
||||
return this.redis.lpush(key, ...stringifiedElements);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) this.logger.error(`IoRedis lpush failed: ${err.message}`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,5 @@ process.env = {
|
||||
CALENDSO_ENCRYPTION_KEY: "22gfxhWUlcKliUeXcu8xNah2+HP/29ZX",
|
||||
INTEGRATION_TEST_MODE: "true",
|
||||
e2e: "true",
|
||||
SLOTS_CACHE_TTL: "1"
|
||||
};
|
||||
|
||||
@@ -34,6 +34,6 @@
|
||||
"eslint-config-next": "15.1.6",
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5"
|
||||
"typescript": "^5.9.0-beta"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { passwordResetRequest } from "@calcom/features/auth/lib/passwordResetReq
|
||||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { piiHasher } from "@calcom/lib/server/PiiHasher";
|
||||
|
||||
async function handler(req: NextRequest) {
|
||||
const body = await parseRequestData(req);
|
||||
@@ -28,7 +29,7 @@ async function handler(req: NextRequest) {
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
rateLimitingType: "core",
|
||||
identifier: ip,
|
||||
identifier: piiHasher.hash(ip),
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
@@ -4,13 +4,16 @@ import { NextResponse } from "next/server";
|
||||
|
||||
import jackson from "@calcom/features/ee/sso/lib/jackson";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import logger from "@calcom/lib/logger";
|
||||
|
||||
// This is the callback endpoint for the OIDC provider
|
||||
// A team must set this endpoint in the OIDC provider's configuration
|
||||
async function handler(req: NextRequest) {
|
||||
const log = logger.getSubLogger({ prefix: ["[ODIC auth]"] });
|
||||
const { searchParams } = req.nextUrl;
|
||||
const code = searchParams.get("code");
|
||||
const state = searchParams.get("state");
|
||||
const tenant = searchParams.get("tenant");
|
||||
|
||||
if (!code || !state) {
|
||||
return NextResponse.json({ message: "Code and state are required" }, { status: 400 });
|
||||
@@ -30,6 +33,7 @@ async function handler(req: NextRequest) {
|
||||
|
||||
return NextResponse.redirect(redirect_url, 302);
|
||||
} catch (err) {
|
||||
log.error(`Error authorizing tenant ${tenant}: ${err}`);
|
||||
const { message, statusCode = 500 } = err as HttpError;
|
||||
|
||||
return NextResponse.json({ message }, { status: statusCode });
|
||||
|
||||
@@ -5,17 +5,20 @@ import { NextResponse } from "next/server";
|
||||
import type { OAuthReq } from "@calcom/features/ee/sso/lib/jackson";
|
||||
import jackson from "@calcom/features/ee/sso/lib/jackson";
|
||||
import type { HttpError } from "@calcom/lib/http-error";
|
||||
import logger from "@calcom/lib/logger";
|
||||
|
||||
async function handler(req: NextRequest) {
|
||||
const log = logger.getSubLogger({ prefix: ["[SAML authorize]"] });
|
||||
const { oauthController } = await jackson();
|
||||
|
||||
const oAuthReq = Object.fromEntries(req.nextUrl.searchParams) as unknown as OAuthReq;
|
||||
|
||||
try {
|
||||
const { redirect_url } = await oauthController.authorize(
|
||||
Object.fromEntries(req.nextUrl.searchParams) as unknown as OAuthReq
|
||||
);
|
||||
const { redirect_url } = await oauthController.authorize(oAuthReq);
|
||||
|
||||
return NextResponse.redirect(redirect_url as string, 302);
|
||||
} catch (err) {
|
||||
log.error(`Error initaiting SAML login for tenant ${oAuthReq?.tenant}: ${err}`);
|
||||
const { message, statusCode = 500 } = err as HttpError;
|
||||
|
||||
return NextResponse.json({ message }, { status: statusCode });
|
||||
|
||||
@@ -2,21 +2,32 @@ import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
|
||||
import { parseRequestData } from "app/api/parseRequestData";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import { uuid } from "short-uuid";
|
||||
|
||||
import jackson from "@calcom/features/ee/sso/lib/jackson";
|
||||
import type { SAMLResponsePayload } from "@calcom/features/ee/sso/lib/jackson";
|
||||
import logger from "@calcom/lib/logger";
|
||||
|
||||
async function handler(req: NextRequest) {
|
||||
const log = logger.getSubLogger({ prefix: ["[SAML callback]"] });
|
||||
const { oauthController } = await jackson();
|
||||
|
||||
const { redirect_url } = await oauthController.samlResponse(
|
||||
(await parseRequestData(req)) as SAMLResponsePayload
|
||||
);
|
||||
const requestData = (await parseRequestData(req)) as SAMLResponsePayload;
|
||||
|
||||
const { redirect_url, error } = await oauthController.samlResponse(requestData);
|
||||
|
||||
if (redirect_url) {
|
||||
return NextResponse.redirect(redirect_url, 302);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
const uid = uuid();
|
||||
log.error(
|
||||
`Error authenticating user with error ${error} for relayState ${requestData?.RelayState} trace:${uid}`
|
||||
);
|
||||
return NextResponse.json({ message: `Error authorizing user. trace: ${uid}` }, { status: 400 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "No redirect URL provided" }, { status: 400 });
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,26 @@ import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
|
||||
import { parseRequestData } from "app/api/parseRequestData";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import { uuid } from "short-uuid";
|
||||
|
||||
import jackson from "@calcom/features/ee/sso/lib/jackson";
|
||||
import type { OAuthTokenReq } from "@calcom/features/ee/sso/lib/jackson";
|
||||
import logger from "@calcom/lib/logger";
|
||||
|
||||
async function handler(req: NextRequest) {
|
||||
const { oauthController } = await jackson();
|
||||
const tokenResponse = await oauthController.token((await parseRequestData(req)) as OAuthTokenReq);
|
||||
return NextResponse.json(tokenResponse);
|
||||
const log = logger.getSubLogger({ prefix: ["[SAML token]"] });
|
||||
|
||||
const oauthTokenReq = (await parseRequestData(req)) as OAuthTokenReq;
|
||||
|
||||
try {
|
||||
const tokenResponse = await oauthController.token(oauthTokenReq);
|
||||
return NextResponse.json(tokenResponse);
|
||||
} catch (error) {
|
||||
const uid = uuid();
|
||||
log.error(`Error getting auth token for client id ${oauthTokenReq?.client_id}: ${error} trace: ${uid}`);
|
||||
throw new Error(`Error getting auth token with error ${error} trace: ${uid}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const POST = defaultResponderForAppDir(handler);
|
||||
|
||||
@@ -1,23 +1,33 @@
|
||||
import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import z from "zod";
|
||||
import { uuid } from "short-uuid";
|
||||
import { z } from "zod";
|
||||
|
||||
import jackson from "@calcom/features/ee/sso/lib/jackson";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import logger from "@calcom/lib/logger";
|
||||
|
||||
const extractAuthToken = (req: NextRequest) => {
|
||||
const log = logger.getSubLogger({ prefix: ["SAML extractAuthToken"] });
|
||||
const uid = uuid();
|
||||
const authHeader = req.headers.get("authorization");
|
||||
const parts = (authHeader || "").split(" ");
|
||||
if (parts.length > 1) return parts[1];
|
||||
|
||||
// check for query param
|
||||
let arr: string[] = [];
|
||||
const { access_token } = requestQuery.parse(Object.fromEntries(req.nextUrl.searchParams));
|
||||
const tokenParse = requestQuery.safeParse(Object.fromEntries(req.nextUrl.searchParams));
|
||||
let access_token;
|
||||
if (!tokenParse.success) {
|
||||
log.error(`Error parsing request query: ${tokenParse.error} trace ${uid}`);
|
||||
throw new HttpError({ statusCode: 401, message: `Unauthorized trace: ${uid}` });
|
||||
}
|
||||
access_token = tokenParse.data.access_token;
|
||||
arr = arr.concat(access_token);
|
||||
if (arr[0].length > 0) return arr[0];
|
||||
|
||||
throw new HttpError({ statusCode: 401, message: "Unauthorized" });
|
||||
throw new HttpError({ statusCode: 401, message: `Unauthorized trace: ${uid}` });
|
||||
};
|
||||
|
||||
const requestQuery = z.object({
|
||||
@@ -25,10 +35,18 @@ const requestQuery = z.object({
|
||||
});
|
||||
|
||||
async function handler(req: NextRequest) {
|
||||
const log = logger.getSubLogger({ prefix: ["SAML userinfo"] });
|
||||
const { oauthController } = await jackson();
|
||||
const token = extractAuthToken(req);
|
||||
const userInfo = await oauthController.userInfo(token);
|
||||
return NextResponse.json(userInfo);
|
||||
|
||||
try {
|
||||
const userInfo = await oauthController.userInfo(token);
|
||||
return NextResponse.json(userInfo);
|
||||
} catch (error) {
|
||||
const uid = uuid();
|
||||
log.error(`trace: ${uid} Error getting user info from token: ${error}`);
|
||||
throw new Error(`Error getting user info from token. trace: ${uid}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const GET = defaultResponderForAppDir(handler);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
|
||||
|
||||
import { handleQueuedFormResponseCleanup } from "@calcom/app-store/routing-forms/cron/queuedFormResponseCleanup";
|
||||
|
||||
export const POST = defaultResponderForAppDir(handleQueuedFormResponseCleanup);
|
||||
@@ -208,7 +208,7 @@ async function getHandler(request: NextRequest) {
|
||||
}
|
||||
|
||||
// Create a new response with the image buffer
|
||||
const imageResponse = new NextResponse(buffer);
|
||||
const imageResponse = new NextResponse(buffer as BodyInit);
|
||||
|
||||
// Set the appropriate headers
|
||||
imageResponse.headers.set("Content-Type", response.headers.get("content-type") || "image/png");
|
||||
|
||||
@@ -35,20 +35,31 @@ async function handler(req: NextRequest) {
|
||||
const imageType = searchParams.get("type");
|
||||
|
||||
try {
|
||||
const [calFontData, interFontData, interFontMediumData] = await Promise.all([
|
||||
const fontResults = await Promise.allSettled([
|
||||
fetch(new URL("/fonts/cal.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
|
||||
fetch(new URL("/fonts/Inter-Regular.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
|
||||
fetch(new URL("/fonts/Inter-Medium.ttf", WEBAPP_URL)).then((res) => res.arrayBuffer()),
|
||||
]);
|
||||
|
||||
const fonts: SatoriOptions["fonts"] = [];
|
||||
|
||||
if (fontResults[1].status === "fulfilled") {
|
||||
fonts.push({ name: "inter", data: fontResults[1].value, weight: 400 });
|
||||
}
|
||||
|
||||
if (fontResults[2].status === "fulfilled") {
|
||||
fonts.push({ name: "inter", data: fontResults[2].value, weight: 500 });
|
||||
}
|
||||
|
||||
if (fontResults[0].status === "fulfilled") {
|
||||
fonts.push({ name: "cal", data: fontResults[0].value, weight: 400 });
|
||||
fonts.push({ name: "cal", data: fontResults[0].value, weight: 600 });
|
||||
}
|
||||
|
||||
const ogConfig = {
|
||||
width: 1200,
|
||||
height: 630,
|
||||
fonts: [
|
||||
{ name: "inter", data: interFontData, weight: 400 },
|
||||
{ name: "inter", data: interFontMediumData, weight: 500 },
|
||||
{ name: "cal", data: calFontData, weight: 400 },
|
||||
{ name: "cal", data: calFontData, weight: 600 },
|
||||
] as SatoriOptions["fonts"],
|
||||
fonts,
|
||||
};
|
||||
|
||||
switch (imageType) {
|
||||
|
||||
@@ -546,9 +546,7 @@ function BookingListItem(booking: BookingItemProps) {
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
data-testid="title-and-attendees"
|
||||
className={`w-full px-4${isRejected ? " line-through" : ""}`}>
|
||||
<div data-testid="title-and-attendees" className={`w-full px-4${isRejected ? "line-through" : ""}`}>
|
||||
<Link href={bookingLink}>
|
||||
{/* Time and Badges for mobile */}
|
||||
<div className="w-full pb-2 pt-4 sm:hidden">
|
||||
@@ -893,7 +891,7 @@ const FirstAttendee = ({
|
||||
) : (
|
||||
<a
|
||||
key={user.email}
|
||||
className=" hover:text-blue-500"
|
||||
className="hover:text-blue-500"
|
||||
href={`mailto:${user.email}`}
|
||||
onClick={(e) => e.stopPropagation()}>
|
||||
{user.name || user.email}
|
||||
@@ -1081,7 +1079,7 @@ const GroupedAttendees = (groupedAttendeeProps: GroupedAttendeeProps) => {
|
||||
/>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<div className="flex justify-end p-2 ">
|
||||
<div className="flex justify-end p-2">
|
||||
<Button
|
||||
data-testid="update-no-show"
|
||||
color="secondary"
|
||||
@@ -1204,7 +1202,7 @@ const GroupedGuests = ({ guests }: { guests: AttendeeProps[] }) => {
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<div className="flex justify-end space-x-2 p-2 ">
|
||||
<div className="flex justify-end space-x-2 p-2">
|
||||
<Link href={`mailto:${selectedEmail}`}>
|
||||
<Button
|
||||
color="secondary"
|
||||
|
||||
@@ -278,13 +278,14 @@ describe("Booking Actions", () => {
|
||||
expect(rerouteAction).toBeDefined();
|
||||
});
|
||||
|
||||
it("should include reassign action for round robin events", () => {
|
||||
it("should include reassign action for round robin events with no host groups", () => {
|
||||
const context = createMockContext({
|
||||
booking: {
|
||||
...createMockContext().booking,
|
||||
eventType: {
|
||||
...createMockContext().booking.eventType,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
hostGroups: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -294,6 +295,60 @@ describe("Booking Actions", () => {
|
||||
expect(reassignAction).toBeDefined();
|
||||
});
|
||||
|
||||
it("should include reassign action for round robin events with one host group", () => {
|
||||
const context = createMockContext({
|
||||
booking: {
|
||||
...createMockContext().booking,
|
||||
eventType: {
|
||||
...createMockContext().booking.eventType,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
hostGroups: [{ id: "group-1", name: "Group 1" }],
|
||||
},
|
||||
},
|
||||
});
|
||||
const actions = getEditEventActions(context);
|
||||
|
||||
const reassignAction = actions.find((a) => a.id === "reassign");
|
||||
expect(reassignAction).toBeDefined();
|
||||
});
|
||||
|
||||
it("should exclude reassign action for round robin events with more than one host groups", () => {
|
||||
const context = createMockContext({
|
||||
booking: {
|
||||
...createMockContext().booking,
|
||||
eventType: {
|
||||
...createMockContext().booking.eventType,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
hostGroups: [
|
||||
{ id: "group-1", name: "Group 1" },
|
||||
{ id: "group-2", name: "Group 2" },
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
const actions = getEditEventActions(context);
|
||||
|
||||
const reassignAction = actions.find((a) => a.id === "reassign");
|
||||
expect(reassignAction).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should exclude reassign action for non-round-robin events", () => {
|
||||
const context = createMockContext({
|
||||
booking: {
|
||||
...createMockContext().booking,
|
||||
eventType: {
|
||||
...createMockContext().booking.eventType,
|
||||
schedulingType: SchedulingType.COLLECTIVE,
|
||||
hostGroups: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
const actions = getEditEventActions(context);
|
||||
|
||||
const reassignAction = actions.find((a) => a.id === "reassign");
|
||||
expect(reassignAction).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should exclude add_members when guests are disabled", () => {
|
||||
const context = createMockContext({
|
||||
booking: {
|
||||
|
||||
@@ -146,8 +146,9 @@ export function getEditEventActions(context: BookingActionContext): ActionType[]
|
||||
icon: "user-plus",
|
||||
disabled: false,
|
||||
},
|
||||
// Reassign (if round robin)
|
||||
booking.eventType.schedulingType === SchedulingType.ROUND_ROBIN
|
||||
// Reassign if round robin with no or one host groups
|
||||
booking.eventType.schedulingType === SchedulingType.ROUND_ROBIN &&
|
||||
(!booking.eventType.hostGroups || booking.eventType.hostGroups?.length <= 1)
|
||||
? {
|
||||
id: "reassign",
|
||||
label: t("reassign"),
|
||||
|
||||
+2
-2
@@ -144,7 +144,7 @@ const PlainContactForm = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="absolute bottom-4 right-4 z-50">
|
||||
<div className="absolute bottom-[1rem] right-[1rem] z-50">
|
||||
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
||||
<PopoverTrigger asChild className="enabled:hover:bg-subtle bg-subtle shadow-none">
|
||||
<Button
|
||||
@@ -156,7 +156,7 @@ const PlainContactForm = () => {
|
||||
|
||||
<PopoverContent
|
||||
style={{ maxWidth: "450px", maxHeight: "650px" }}
|
||||
className="!bg-muted no-scrollbar mr-8 mb-2 w-[450px] overflow-hidden overflow-y-scroll px-6 py-4">
|
||||
className="!bg-muted no-scrollbar mb-2 mr-8 w-[450px] overflow-hidden overflow-y-scroll px-6 py-4">
|
||||
<div className="flex w-full justify-between">
|
||||
<p className="mb-5 text-lg font-semibold">Contact support</p>
|
||||
<Button
|
||||
@@ -4,7 +4,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import PlainContactForm from "../../../lib/plain/PlainContactForm";
|
||||
import PlainContactForm from "../PlainContactForm";
|
||||
|
||||
vi.mock("next-auth/react", () => ({
|
||||
useSession: vi.fn(),
|
||||
|
||||
@@ -124,8 +124,9 @@ const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.Component
|
||||
autoComplete="none"
|
||||
autoCapitalize="none"
|
||||
autoCorrect="none"
|
||||
containerClassName="[&>div]:gap-0"
|
||||
className={classNames(
|
||||
"mb-0 mt-0 rounded-md rounded-l-none",
|
||||
"mb-0 mt-0 rounded-md rounded-l-none pl-0",
|
||||
markAsError
|
||||
? "focus:shadow-0 focus:ring-shadow-0 border-red-500 focus:border-red-500 focus:outline-none focus:ring-0"
|
||||
: ""
|
||||
|
||||
@@ -2,4 +2,6 @@ import dynamic from "next/dynamic";
|
||||
import { Fragment } from "react";
|
||||
|
||||
// Preload caused by dynamic import doesn't seem to add nonce and thus preload fails but the functionality still works - https://github.com/vercel/next.js/issues/81260
|
||||
export default process.env.NEXT_PUBLIC_PLAIN_CHAT_ID ? dynamic(() => import("./plainChat")) : Fragment;
|
||||
export default process.env.NEXT_PUBLIC_PLAIN_CHAT_ID
|
||||
? dynamic(() => import("../../components/plain/plainChat"))
|
||||
: Fragment;
|
||||
|
||||
@@ -117,7 +117,7 @@ const checkIfUserIsHost = async ({
|
||||
});
|
||||
|
||||
// If eventType exists, it means user is either owner, host or user
|
||||
return !eventType;
|
||||
return !!eventType;
|
||||
};
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
RecentFeedbackTable,
|
||||
TimezoneBadge,
|
||||
} from "@calcom/features/insights/components/booking";
|
||||
import "@calcom/features/insights/components/tremor.css";
|
||||
import { InsightsOrgTeamsProvider } from "@calcom/features/insights/context/InsightsOrgTeamsProvider";
|
||||
import { Download } from "@calcom/features/insights/filters/Download";
|
||||
import { OrgTeamsFilter } from "@calcom/features/insights/filters/OrgTeamsFilter";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { ProgressBar } from "@tremor/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, useMemo } from "react";
|
||||
@@ -16,6 +15,7 @@ import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
import { TextField, Label, InputError } from "@calcom/ui/components/form";
|
||||
import { ProgressBar } from "@calcom/ui/components/progress-bar";
|
||||
import { showToast } from "@calcom/ui/toast";
|
||||
|
||||
import { BillingCreditsSkeleton } from "./BillingCreditsSkeleton";
|
||||
|
||||
@@ -13,7 +13,7 @@ export const BUTTONS = {
|
||||
iconPathDarkMode: TRANSCRIPTION_STARTED_ICON,
|
||||
},
|
||||
START_TRANSCRIPTION: {
|
||||
label: "Cal.ai",
|
||||
label: "Transcribe",
|
||||
tooltip: "Transcription powered by AI",
|
||||
iconPath: TRANSCRIPTION_STOPPED_ICON,
|
||||
iconPathDarkMode: TRANSCRIPTION_STOPPED_ICON,
|
||||
|
||||
@@ -85,7 +85,7 @@ export default function JoinCall(props: PageProps) {
|
||||
...(showTranscriptionButton
|
||||
? {
|
||||
transcription: {
|
||||
label: "Cal.ai",
|
||||
label: "Transcribe",
|
||||
tooltip: "Transcription powered by AI",
|
||||
iconPath: TRANSCRIPTION_STOPPED_ICON,
|
||||
iconPathDarkMode: TRANSCRIPTION_STOPPED_ICON,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@calcom/web",
|
||||
"version": "5.5.10",
|
||||
"version": "5.5.14",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"analyze": "ANALYZE=true next build",
|
||||
@@ -76,10 +76,9 @@
|
||||
"@stripe/stripe-js": "^1.35.0",
|
||||
"@tanstack/react-query": "^5.17.15",
|
||||
"@team-plain/typescript-sdk": "^5.9.0",
|
||||
"@tremor/react": "^2.11.0",
|
||||
"@types/turndown": "^5.0.1",
|
||||
"@unkey/ratelimit": "^0.1.1",
|
||||
"@upstash/redis": "^1.21.0",
|
||||
"@upstash/redis": "^1.35.2",
|
||||
"@vercel/edge-config": "^0.1.1",
|
||||
"@vercel/edge-functions-ui": "^0.2.1",
|
||||
"@vercel/og": "^0.6.3",
|
||||
@@ -195,7 +194,7 @@
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tailwindcss-animate": "^1.0.6",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.7.2"
|
||||
"typescript": "^5.9.0-beta"
|
||||
},
|
||||
"nextBundleAnalysis": {
|
||||
"budget": 358400,
|
||||
|
||||
@@ -7,6 +7,7 @@ import getIP from "@calcom/lib/getIP";
|
||||
import { checkCfTurnstileToken } from "@calcom/lib/server/checkCfTurnstileToken";
|
||||
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
|
||||
import { CreationSource } from "@calcom/prisma/enums";
|
||||
import { piiHasher } from "@calcom/lib/server/PiiHasher";
|
||||
|
||||
async function handler(req: NextApiRequest & { userId?: number }) {
|
||||
const userIp = getIP(req);
|
||||
@@ -20,7 +21,7 @@ async function handler(req: NextApiRequest & { userId?: number }) {
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
rateLimitingType: "core",
|
||||
identifier: userIp,
|
||||
identifier: piiHasher.hash(userIp),
|
||||
});
|
||||
|
||||
const session = await getServerSession({ req });
|
||||
|
||||
@@ -6,13 +6,14 @@ import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowE
|
||||
import getIP from "@calcom/lib/getIP";
|
||||
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
|
||||
import { CreationSource } from "@calcom/prisma/enums";
|
||||
import { piiHasher } from "@calcom/lib/server/PiiHasher";
|
||||
|
||||
async function handler(req: NextApiRequest & { userId?: number }) {
|
||||
const userIp = getIP(req);
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
rateLimitingType: "core",
|
||||
identifier: `instant.event-${userIp}`,
|
||||
identifier: `instant.event-${piiHasher.hash(userIp)}`,
|
||||
});
|
||||
|
||||
const session = await getServerSession({ req });
|
||||
|
||||
@@ -7,6 +7,7 @@ import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowE
|
||||
import getIP from "@calcom/lib/getIP";
|
||||
import { checkCfTurnstileToken } from "@calcom/lib/server/checkCfTurnstileToken";
|
||||
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
|
||||
import { piiHasher } from "@calcom/lib/server/PiiHasher";
|
||||
|
||||
// @TODO: Didn't look at the contents of this function in order to not break old booking page.
|
||||
|
||||
@@ -37,7 +38,7 @@ async function handler(req: NextApiRequest & RequestMeta) {
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
rateLimitingType: "core",
|
||||
identifier: userIp,
|
||||
identifier: piiHasher.hash(userIp),
|
||||
});
|
||||
const session = await getServerSession({ req });
|
||||
/* To mimic API behavior and comply with types */
|
||||
|
||||
@@ -203,32 +203,24 @@ test.describe("Insights", async () => {
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
// Choose User filter item from dropdown
|
||||
await addFilter(page, "bookingUserId");
|
||||
await addFilter(page, "userId");
|
||||
|
||||
// Wait for the URL to include bookingUserId
|
||||
await page.waitForURL((url) => url.toString().includes("bookingUserId"));
|
||||
// Wait for the URL to include userId
|
||||
await page.waitForURL((url) => url.toString().includes("userId"));
|
||||
|
||||
// Click User filter to see a user list
|
||||
await openFilter(page, "bookingUserId");
|
||||
await openFilter(page, "userId");
|
||||
|
||||
await page
|
||||
.locator('[data-testid="select-filter-options-bookingUserId"]')
|
||||
.getByRole("option")
|
||||
.nth(0)
|
||||
.click();
|
||||
await page.locator('[data-testid="select-filter-options-userId"]').getByRole("option").nth(0).click();
|
||||
|
||||
await page
|
||||
.locator('[data-testid="select-filter-options-bookingUserId"]')
|
||||
.getByRole("option")
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.locator('[data-testid="select-filter-options-userId"]').getByRole("option").nth(1).click();
|
||||
|
||||
// press escape button to close the filter
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
await clearFilters(page);
|
||||
|
||||
await expect(page.url()).not.toContain("bookingUserId");
|
||||
await expect(page.url()).not.toContain("userId");
|
||||
});
|
||||
|
||||
test("should test download button", async ({ page, users }) => {
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
"already_signed_up_for_this_booking_error": "You are already signed up for this booking.",
|
||||
"hosts_unavailable_for_booking": "Some of the hosts are unavailable for booking.",
|
||||
"fixed_hosts_unavailable_for_booking": "Some of the fixed hosts are unavailable for booking.",
|
||||
"round_robin_hosts_unavailable_for_booking": "No Round Robin hosts is available for booking.",
|
||||
"round_robin_host_unavailable_for_booking": "Round Robin host is unavailable for booking.",
|
||||
"help": "Help",
|
||||
"price": "Price",
|
||||
"paid": "Paid",
|
||||
@@ -349,6 +349,7 @@
|
||||
"available_apps_lower_case": "Available apps",
|
||||
"available_apps_desc": "View popular apps below and explore more in our <0>App Store</0>",
|
||||
"fixed_host_helper": "Add anyone who needs to attend the event. <0>Learn more</0>",
|
||||
"round_robin_groups_helper": "People in a group take turns, one person of each group will show up for the event.",
|
||||
"round_robin_helper": "People in the group take turns and only one person will show up for the event.",
|
||||
"check_email_reset_password": "Check your email. We sent you a link to reset your password.",
|
||||
"finish": "Finish",
|
||||
@@ -2251,6 +2252,8 @@
|
||||
"floating_button_trigger_modal": "Puts a floating button on your site that triggers a modal with your event type.",
|
||||
"pop_up_element_click": "Pop up via element click",
|
||||
"open_dialog_with_element_click": "Open your calendar as a dialog when someone clicks an element.",
|
||||
"use_my_own_form": "Use my own form",
|
||||
"use_our_headless_routing_api": "Use our headless routing API and use your own form for submissions.",
|
||||
"need_help_embedding": "Need help? See our guides for embedding Cal on Wix, Squarespace, or WordPress, check our common questions, or explore advanced embed options.",
|
||||
"book_my_cal": "Book my Cal",
|
||||
"first_name": "First name",
|
||||
@@ -3286,6 +3289,7 @@
|
||||
"pbac_resource_booking": "Bookings",
|
||||
"pbac_resource_insights": "Insights",
|
||||
"pbac_resource_role": "Roles",
|
||||
"pbac_resource_workflow": "Workflows",
|
||||
"pbac_action_all": "All Actions",
|
||||
"pbac_action_create": "Create",
|
||||
"pbac_action_read": "View",
|
||||
@@ -3317,6 +3321,11 @@
|
||||
"pbac_desc_update_roles": "Update roles",
|
||||
"pbac_desc_delete_roles": "Delete roles",
|
||||
"pbac_desc_manage_roles": "All actions on roles across organization teams",
|
||||
"pbac_desc_create_workflows": "Create and set up new workflows",
|
||||
"pbac_desc_view_workflows": "View existing workflows and their configurations",
|
||||
"pbac_desc_update_workflows": "Edit and modify workflow settings",
|
||||
"pbac_desc_delete_workflows": "Remove workflows from the system",
|
||||
"pbac_desc_manage_workflows": "Full management access to all workflows",
|
||||
"pbac_desc_create_event_types": "Create event types",
|
||||
"pbac_desc_view_event_types": "View event types",
|
||||
"pbac_desc_update_event_types": "Update event types",
|
||||
@@ -3354,6 +3363,7 @@
|
||||
"use_booker_timezone_info": "Apply the selected restriction schedule in the booker's timezone",
|
||||
"load_balancing_warning": "This will disable Load Balancing on all your Round Robin event types",
|
||||
"rr_load_balancing_disabled": "Load Balancing is only available when the timestamp basis is set to Booking Creation Time",
|
||||
"rr_load_balancing_disabled_with_groups": "Load Balancing is not available with Round Robin Groups",
|
||||
"round_robin_settings_description": "Customize the default round robin settings for this team",
|
||||
"round_robin_settings_updated_successfully": "Round Robin settings updated successfully",
|
||||
"booking_creation_time": "Booking Creation Time",
|
||||
@@ -3370,6 +3380,7 @@
|
||||
"booking_not_allowed_by_restriction_schedule_error": "Booking outside restriction schedule availability.",
|
||||
"restriction_schedule_not_found_error": "Restriction schedule not found",
|
||||
"converted_image_size_limit_exceed": "Image size limit exceeded, please use a smaller image preferably in JPEG format",
|
||||
"add_group": "Add Group",
|
||||
"routing_funnel": "Routing Funnel",
|
||||
"routing_funnel_total_submissions": "Total Submissions",
|
||||
"routing_funnel_successful_routings": "Successful Routings",
|
||||
@@ -3402,6 +3413,7 @@
|
||||
"license_key_saved": "License key saved successfully",
|
||||
"timezone_mismatch_tooltip": "You are viewing the report based on your profile timezone ({{userTimezone}}), while your browser is set to timezone ({{browserTimezone}})",
|
||||
"failed_bookings_by_field": "Failed Bookings By Field",
|
||||
"failed_bookings": "Failed bookings",
|
||||
"event_type_no_hosts": "No hosts are assigned to event type",
|
||||
"cache_status": "Cache Status",
|
||||
"cache_last_updated": "Last updated: {{timestamp}}",
|
||||
@@ -3429,5 +3441,7 @@
|
||||
"usage_based_expiration_description": "This link can be used for {{count}} booking",
|
||||
"usage_based_generic_expiration_description": "This link can be configured to expire after a set number of bookings",
|
||||
"usage_based_expiration_description_plural": "This link can be used for {{count}} bookings",
|
||||
"stats": "Stats",
|
||||
"booking_status": "Booking status",
|
||||
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@
|
||||
"connect": "Ühenda",
|
||||
"try_for_free": "Proovi tasuta",
|
||||
"create_booking_link_with_calcom": "Looge oma broneerimislink rakendusega {{appName}}",
|
||||
"who": "WHO",
|
||||
"who": "Kes",
|
||||
"what": "Mida",
|
||||
"when": "Millal",
|
||||
"where": "Kus",
|
||||
|
||||
@@ -2,10 +2,6 @@ const base = require("@calcom/config/tailwind-preset");
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
...base,
|
||||
content: [
|
||||
...base.content,
|
||||
"../../packages/app-store/routing-forms/**/*.{js,ts,jsx,tsx}",
|
||||
"../../node_modules/@tremor/**/*.{js,ts,jsx,tsx}",
|
||||
],
|
||||
content: [...base.content, "../../packages/app-store/routing-forms/**/*.{js,ts,jsx,tsx}"],
|
||||
plugins: [...base.plugins, require("tailwindcss-animate")],
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import CalendarManagerMock from "../../../../tests/libs/__mocks__/CalendarManager";
|
||||
import { constantsScenarios } from "@calcom/lib/__mocks__/constants";
|
||||
|
||||
import {
|
||||
getDate,
|
||||
@@ -23,12 +24,12 @@ import { expect, expectedSlotsForSchedule } from "./getSchedule/expects";
|
||||
import { setupAndTeardown } from "./getSchedule/setupAndTeardown";
|
||||
import { timeTravelToTheBeginningOfToday } from "./getSchedule/utils";
|
||||
|
||||
vi.mock("@calcom/lib/constants", () => ({
|
||||
IS_PRODUCTION: true,
|
||||
constantsScenarios.set({
|
||||
IS_PRODUCTION: true as any,
|
||||
WEBAPP_URL: "http://localhost:3000",
|
||||
RESERVED_SUBDOMAINS: ["auth", "docs"],
|
||||
SINGLE_ORG_SLUG: "",
|
||||
}));
|
||||
RESERVED_SUBDOMAINS: ["auth", "docs"] as any,
|
||||
SINGLE_ORG_SLUG: "" as any,
|
||||
});
|
||||
|
||||
describe("getSchedule", () => {
|
||||
const availableSlotsService = getAvailableSlotsService();
|
||||
|
||||
@@ -26,7 +26,12 @@ vi.mock("@calcom/emails/email-manager", () => {
|
||||
|
||||
vi.mock("@calcom/lib/server/i18n", () => {
|
||||
return {
|
||||
getTranslation: (key: string) => key,
|
||||
getTranslation: async (locale: string, namespace: string) => {
|
||||
const t = (key: string) => key;
|
||||
t.locale = locale;
|
||||
t.namespace = namespace;
|
||||
return t;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ type InputHost = {
|
||||
userId: number;
|
||||
isFixed?: boolean;
|
||||
scheduleId?: number | null;
|
||||
groupId?: string | null;
|
||||
};
|
||||
|
||||
type InputSelectedSlot = {
|
||||
@@ -215,6 +216,7 @@ export type InputEventType = {
|
||||
useEventLevelSelectedCalendars?: boolean;
|
||||
users?: { id: number }[];
|
||||
hosts?: InputHost[];
|
||||
hostGroups?: { id: string; name: string }[];
|
||||
schedulingType?: SchedulingType;
|
||||
parent?: { id: number };
|
||||
beforeEventBuffer?: number;
|
||||
@@ -290,6 +292,17 @@ export const Timezones = {
|
||||
|
||||
async function addHostsToDb(eventTypes: InputEventType[]) {
|
||||
for (const eventType of eventTypes) {
|
||||
// Create host groups first if they exist
|
||||
if (eventType.hostGroups?.length) {
|
||||
await prismock.hostGroup.createMany({
|
||||
data: eventType.hostGroups.map((group) => ({
|
||||
id: group.id, // Preserve the input ID
|
||||
name: group.name,
|
||||
eventTypeId: eventType.id,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
if (!eventType.hosts?.length) continue;
|
||||
for (const host of eventType.hosts) {
|
||||
const data: Prisma.HostCreateInput = {
|
||||
@@ -311,6 +324,13 @@ async function addHostsToDb(eventTypes: InputEventType[]) {
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
group: host.groupId
|
||||
? {
|
||||
connect: {
|
||||
id: host.groupId,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
|
||||
await prismock.host.create({
|
||||
@@ -363,6 +383,7 @@ export async function addEventTypesToDb(
|
||||
workflows: true,
|
||||
destinationCalendar: true,
|
||||
schedule: true,
|
||||
hostGroups: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -473,6 +494,7 @@ export async function addEventTypes(eventTypes: InputEventType[], usersStore: In
|
||||
workflows: [],
|
||||
users,
|
||||
hosts,
|
||||
hostGroups: eventType.hostGroups || [],
|
||||
destinationCalendar: eventType.destinationCalendar
|
||||
? {
|
||||
create: eventType.destinationCalendar,
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
"path": "/api/cron/calendar-cache-cleanup",
|
||||
"schedule": "0 5 * * *"
|
||||
},
|
||||
{
|
||||
"path": "/api/cron/queuedFormResponseCleanup",
|
||||
"schedule": "0 */12 * * *"
|
||||
},
|
||||
{
|
||||
"path": "/api/tasks/cron",
|
||||
"schedule": "* * * * *"
|
||||
|
||||
+825
-3526
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,180 @@
|
||||
---
|
||||
title: "How to Add a New Booking Chart to Cal.com Insights Page"
|
||||
---
|
||||
|
||||
This guide walks you through creating a new booking chart component for the insights page, covering the entire stack from UI component to backend service.
|
||||
|
||||
## Overview
|
||||
|
||||
The insights booking system follows this architecture:
|
||||
|
||||
```
|
||||
UI Component → tRPC Handler → Insights Service → Database Query → Response
|
||||
```
|
||||
|
||||
<Steps>
|
||||
<Step title="Create the UI Component">
|
||||
|
||||
Create your chart component in `packages/features/insights/components/booking/`:
|
||||
|
||||
```typescript
|
||||
// packages/features/insights/components/booking/MyNewChart.tsx
|
||||
import { LineChart, XAxis, YAxis, CartesianGrid, Tooltip, Line, ResponsiveContainer } from "recharts";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc";
|
||||
|
||||
import { useInsightsBookingParameters } from "../../hooks/useInsightsBookingParameters";
|
||||
import { ChartCard } from "../ChartCard";
|
||||
import { LoadingInsight } from "../LoadingInsights";
|
||||
|
||||
export const MyNewChart = () => {
|
||||
const { t } = useLocale();
|
||||
const insightsBookingParams = useInsightsBookingParameters();
|
||||
|
||||
const { data, isSuccess, isPending } = trpc.viewer.insights.myNewChartData.useQuery(insightsBookingParams, {
|
||||
staleTime: 180000, // 3 minutes
|
||||
refetchOnWindowFocus: false,
|
||||
trpc: { context: { skipBatch: true } },
|
||||
});
|
||||
|
||||
if (isPending) return <LoadingInsight />;
|
||||
|
||||
return (
|
||||
<ChartCard title={t("my_new_chart_title")}>
|
||||
{isSuccess && data?.length > 0 ? (
|
||||
<ResponsiveContainer width="100%" height={300}>
|
||||
<LineChart data={data}>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
<XAxis dataKey="date" />
|
||||
<YAxis />
|
||||
<Tooltip />
|
||||
<Line type="monotone" dataKey="value" stroke="#8884d8" strokeWidth={2} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
) : (
|
||||
<div className="flex h-64 items-center justify-center">
|
||||
<p className="text-gray-500">{t("no_data_yet")}</p>
|
||||
</div>
|
||||
)}
|
||||
</ChartCard>
|
||||
);
|
||||
};
|
||||
```
|
||||
</Step>
|
||||
<Step title="Add Component to Barrel Export">
|
||||
Update the booking components index file:
|
||||
|
||||
```typescript
|
||||
// packages/features/insights/components/booking/index.ts
|
||||
export { AverageEventDurationChart } from "./AverageEventDurationChart";
|
||||
export { BookingKPICards } from "./BookingKPICards";
|
||||
// ... existing exports
|
||||
export { MyNewChart } from "./MyNewChart"; // Add this line
|
||||
```
|
||||
</Step>
|
||||
<Step title="Add Component to Insights View">
|
||||
|
||||
Add your component to the main insights page:
|
||||
|
||||
```typescript
|
||||
// apps/web/modules/insights/insights-view.tsx
|
||||
import {
|
||||
AverageEventDurationChart,
|
||||
BookingKPICards, // ... existing imports
|
||||
MyNewChart, // Add this import
|
||||
} from "@calcom/features/insights/components/booking";
|
||||
|
||||
export default function InsightsPage() {
|
||||
// ... existing code
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Existing components */}
|
||||
<BookingKPICards />
|
||||
<EventTrendsChart />
|
||||
|
||||
{/* Add your new chart */}
|
||||
<MyNewChart />
|
||||
|
||||
{/* Other existing components */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create tRPC Handler">
|
||||
|
||||
Add the tRPC endpoint in the insights router using the `getInsightsBookingService()` DI container function:
|
||||
|
||||
```typescript
|
||||
// packages/features/insights/server/trpc-router.ts
|
||||
import { bookingRepositoryBaseInputSchema } from "@calcom/features/insights/server/raw-data.schema";
|
||||
import { userBelongsToTeamProcedure } from "@calcom/trpc/server/procedures/authedProcedure";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
export const insightsRouter = router({
|
||||
// ... existing procedures
|
||||
|
||||
myNewChartData: userBelongsToTeamProcedure
|
||||
.input(bookingRepositoryBaseInputSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
// `createInsightsBookingService` is defined at the root level in this file
|
||||
const insightsBookingService = createInsightsBookingService(ctx, input);
|
||||
|
||||
try {
|
||||
return await insightsBookingService.getMyNewChartData();
|
||||
} catch (e) {
|
||||
throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });
|
||||
}
|
||||
}),
|
||||
});
|
||||
```
|
||||
</Step>
|
||||
<Step title="Add Service Method to InsightsBookingBaseService">
|
||||
Add your new method to the `InsightsBookingBaseService` class:
|
||||
|
||||
```typescript
|
||||
// packages/lib/server/service/InsightsBookingBaseService.ts
|
||||
export class InsightsBookingBaseService {
|
||||
// ... existing methods
|
||||
|
||||
async getMyNewChartData() {
|
||||
const baseConditions = await this.getBaseConditions();
|
||||
|
||||
// Example: Get booking counts by day using raw SQL for performance
|
||||
const data = await this.prisma.$queryRaw<
|
||||
Array<{
|
||||
date: Date;
|
||||
bookingsCount: number;
|
||||
}>
|
||||
>`
|
||||
SELECT
|
||||
DATE("createdAt") as date,
|
||||
COUNT(*)::int as "bookingsCount"
|
||||
FROM "BookingTimeStatusDenormalized"
|
||||
WHERE ${baseConditions}
|
||||
GROUP BY DATE("createdAt")
|
||||
ORDER BY date ASC
|
||||
`;
|
||||
|
||||
// Transform the data for the chart
|
||||
return data.map((item) => ({
|
||||
date: item.date.toISOString().split("T")[0], // Format as YYYY-MM-DD
|
||||
value: item.bookingsCount,
|
||||
}));
|
||||
}
|
||||
}
|
||||
```
|
||||
</Step>
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use `getInsightsBookingService()`**: Always use the DI container function for consistent service creation
|
||||
2. **Raw SQL for Performance**: Use `$queryRaw` for complex aggregations and better performance
|
||||
3. **Base Conditions**: Always use `await this.getBaseConditions()` for proper filtering and permissions
|
||||
4. **Error Handling**: Wrap service calls in try-catch blocks with `TRPCError`
|
||||
5. **Loading States**: Always show loading indicators with `LoadingInsight`
|
||||
6. **Consistent Styling**: Use `recharts` for new charts.
|
||||
7. **Date Handling**: Use `getDateRanges()` and `getTimeView()` for time-based charts
|
||||
@@ -109,6 +109,11 @@
|
||||
"group": "Embeds",
|
||||
"icon": "code-simple",
|
||||
"pages": ["developing/guides/embeds/embed-events"]
|
||||
},
|
||||
{
|
||||
"group": "Insights",
|
||||
"icon": "chart-bar",
|
||||
"pages": ["developing/guides/insights/add-new-booking-charts"]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -156,7 +156,16 @@ export function AvailabilityWithValidation() {
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
availabilityRef.current?.handleFormSubmit();
|
||||
availabilityRef.current?.handleFormSubmit({
|
||||
onSuccess: () => {
|
||||
// Additional success handling logic here
|
||||
console.log('Availability updated successfully');
|
||||
},
|
||||
onError: (error) => {
|
||||
// Additional error handling logic here
|
||||
console.error('Error updating availability:', error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -184,6 +193,20 @@ export function AvailabilityWithValidation() {
|
||||
| validateForm | Validates the current availability form state and returns a promise with validation results. |
|
||||
| handleFormSubmit | Programmatically submits the availability form, triggering the same validation and submission flow as clicking the save button. Unlike `validateForm`, this method will check required fields and prevent submission unless all required fields are set |
|
||||
|
||||
### Callbacks
|
||||
|
||||
The `handleFormSubmit` method accepts an optional callbacks object with the following properties:
|
||||
|
||||
```typescript
|
||||
type AvailabilitySettingsFormCallbacks = {
|
||||
onSuccess?: () => void;
|
||||
onError?: (error: Error) => void;
|
||||
};
|
||||
```
|
||||
|
||||
- **onSuccess**: Called when the form submission is successful. This allows you to execute additional logic after a successful update.
|
||||
- **onError**: Called when an error occurs during form submission. The error parameter contains details about what went wrong, allowing you to handle specific error cases or display custom error messages.
|
||||
|
||||
The `validateForm` method returns an `AvailabilityFormValidationResult` object with:
|
||||
- `isValid`: Boolean indicating if the form passed validation
|
||||
- `errors`: Object containing any validation errors found
|
||||
|
||||
@@ -126,6 +126,7 @@ Below is a list of props that can be passed to the booker atom.
|
||||
| confirmButtonDisabled | No | Boolean indicating if the submit button should be disabled, defaults to false. |
|
||||
| timeZones | No | Array of valid IANA timezones to be used in the booker. Eg. ["Asia/Kolkata", "Europe/London"] |
|
||||
| onTimeslotsLoaded | No | Callback function triggered once the available timeslots have been fetched. |
|
||||
| roundRobinHideOrgAndTeam | No | Boolean indicating if the organization and team should be hidden in the booker atom sidebar for round robin scheduling type, defaults to false. |
|
||||
|
||||
## Styling
|
||||
|
||||
|
||||
@@ -218,7 +218,16 @@ export function EventTypeWithValidation(eventTypeId: number) {
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
eventTypeRef.current?.handleFormSubmit();
|
||||
eventTypeRef.current?.handleFormSubmit({
|
||||
onSuccess: () => {
|
||||
// Additional success handling logic here
|
||||
console.log('Event type updated successfully');
|
||||
},
|
||||
onError: (error) => {
|
||||
// Additional error handling logic here
|
||||
console.error('Error updating event type:', error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -244,6 +253,20 @@ export function EventTypeWithValidation(eventTypeId: number) {
|
||||
| validateForm | Validates the current event type form state and returns a promise with validation results. |
|
||||
| handleFormSubmit | Programmatically submits the event type form, triggering the same validation and submission flow as clicking the save button. Unlike `validateForm`, this method will check required fields and prevent submission unless all required fields are set |
|
||||
|
||||
### Callbacks
|
||||
|
||||
The `handleFormSubmit` method accepts an optional callbacks object with the following properties:
|
||||
|
||||
```typescript
|
||||
type EventTypeFormCallbacks = {
|
||||
onSuccess?: () => void;
|
||||
onError?: (error: Error) => void;
|
||||
};
|
||||
```
|
||||
|
||||
- **onSuccess**: Called when the form submission is successful. This allows you to execute additional logic after a successful update.
|
||||
- **onError**: Called when an error occurs during form submission. The error parameter contains details about what went wrong, allowing you to handle specific error cases or display custom error messages.
|
||||
|
||||
The `validateForm` method returns an `EventTypeFormValidationResult` object with:
|
||||
- `isValid`: Boolean indicating if the form passed validation
|
||||
- `errors`: Object containing any validation errors found
|
||||
|
||||
+2
-1
@@ -109,7 +109,7 @@
|
||||
"prismock": "^1.33.4",
|
||||
"resize-observer-polyfill": "^1.5.1",
|
||||
"tsc-absolute": "^1.0.0",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript": "5.9.0-beta",
|
||||
"vitest": "^2.1.1",
|
||||
"vitest-fetch-mock": "^0.3.0",
|
||||
"vitest-mock-extended": "^2.0.2"
|
||||
@@ -118,6 +118,7 @@
|
||||
"@daily-co/daily-js": "^0.76.0",
|
||||
"@evyweb/ioctopus": "^1.2.0",
|
||||
"@next/third-parties": "^14.2.5",
|
||||
"@unkey/ratelimit": "^2.1.2",
|
||||
"@vercel/functions": "^1.4.0",
|
||||
"city-timezones": "^1.2.1",
|
||||
"date-fns-tz": "^3.2.0",
|
||||
|
||||
@@ -31,6 +31,6 @@
|
||||
"eslint-plugin-react": "^7.30.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.7.2"
|
||||
"typescript": "^5.9.0-beta"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,13 @@ const EventTypeAppSettingsInterface: EventTypeAppSettingsComponent = ({
|
||||
) : (
|
||||
requirePayment && (
|
||||
<>
|
||||
<div className="mt-4 block items-center justify-start sm:flex sm:space-x-2">
|
||||
<div className="mt-4 inline-block">
|
||||
<label className="text-default block text-sm font-medium mb-1" htmlFor="price">
|
||||
{t("price")}
|
||||
</label>
|
||||
<TextField
|
||||
label={t("price")}
|
||||
className="text-black"
|
||||
className="text-black dark:text-white w-auto"
|
||||
addOnClassname="h-[38px]"
|
||||
min="1"
|
||||
type="number"
|
||||
@@ -88,7 +91,6 @@ const EventTypeAppSettingsInterface: EventTypeAppSettingsComponent = ({
|
||||
variant="default"
|
||||
options={currencyOptions}
|
||||
value={selectedCurrency}
|
||||
className="text-black"
|
||||
defaultValue={selectedCurrency}
|
||||
onChange={(e) => {
|
||||
if (e) {
|
||||
@@ -132,3 +134,4 @@ const EventTypeAppSettingsInterface: EventTypeAppSettingsComponent = ({
|
||||
};
|
||||
|
||||
export default EventTypeAppSettingsInterface;
|
||||
|
||||
|
||||
@@ -1,9 +1,35 @@
|
||||
export const currencyOptions = [
|
||||
{ label: "SATS", value: "BTC", unit: "SATS" },
|
||||
{ label: "USD", value: "USD", unit: "USD" },
|
||||
{ label: "USD- US Dollar", value: "USD", unit: "USD" },
|
||||
{ label: "EUR- Euro", value: "EUR", unit: "EUR" },
|
||||
{ label: "JPY- Japanese Yen", value: "JPY", unit: "JPY" },
|
||||
{ label: "CNY- Yuan Renminbi", value: "CNY", unit: "CNY" },
|
||||
{ label: "GBP- Pounds Sterling", value: "GBP", unit: "GBP" },
|
||||
{ label: "AED- UAE Dirham", value: "AED", unit: "AED" },
|
||||
{ label: "ZAR- South African Rand", value: "ZAR", unit: "ZAR" },
|
||||
{ label: "HKD- Hong Kong Dollar", value: "HKD", unit: "HKD" },
|
||||
{ label: "BRL- Brazilian Real", value: "BRL", unit: "BRL" },
|
||||
{ label: "AUD- Australian Dollar", value: "AUD", unit: "AUD" },
|
||||
{ label: "CAD- Canadian Dollar", value: "CAD", unit: "CAD" },
|
||||
{ label: "CZK- Czech Koruna", value: "CZK", unit: "CZK" },
|
||||
{ label: "DKK- Danish Krone", value: "DKK", unit: "DKK" },
|
||||
{ label: "NZD- New Zealand Dollar", value: "NZD", unit: "NZD" },
|
||||
{ label: "MYR- Malaysian Ringgit", value: "MYR", unit: "MYR" },
|
||||
{ label: "PHP- Philippine Peso", value: "PHP", unit: "PHP" },
|
||||
{ label: "CHF- Swiss Franc", value: "CHF", unit: "CHF" },
|
||||
{ label: "NOK- Norwegian Krone", value: "NOK", unit: "NOK" },
|
||||
{ label: "THB- Thai Baht", value: "THB", unit: "THB" },
|
||||
{ label: "SEK- Swedish Krona", value: "SEK", unit: "SEK" },
|
||||
{ label: "SGD- Singapore Dollar", value: "SGD", unit: "SGD" },
|
||||
{ label: "PLN- Polish Zloty", value: "PLN", unit: "PLN" },
|
||||
{ label: "TWD- New Taiwan Dollar", value: "TWD", unit: "TWD" },
|
||||
{ label: "MXN- Mexican Peso", value: "MXN", unit: "MXN" },
|
||||
{ label: "ILS- New Isreali Shekel", value: "ILS", unit: "ILS" },
|
||||
{ label: "NGN- Nigerian Naira", value: "NGN", unit: "NGN" }
|
||||
];
|
||||
|
||||
const zeroDecimalCurrencies = ["SATS", "BTC"];
|
||||
|
||||
const zeroDecimalCurrencies = ["SATS", "BTC", "JPY"];
|
||||
|
||||
export const convertToSmallestCurrencyUnit = (amount: number, currency: string) => {
|
||||
if (zeroDecimalCurrencies.includes(currency.toUpperCase())) {
|
||||
@@ -17,4 +43,4 @@ export const convertFromSmallestToPresentableCurrencyUnit = (amount: number, cur
|
||||
return amount;
|
||||
}
|
||||
return amount / 100;
|
||||
};
|
||||
};
|
||||
@@ -1114,4 +1114,18 @@ export default class GoogleCalendarService implements Calendar {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getMainTimeZone(): Promise<string> {
|
||||
try {
|
||||
const primaryCalendar = await this.getPrimaryCalendar();
|
||||
if (!primaryCalendar?.timeZone) {
|
||||
this.log.warn("No timezone found in primary calendar, defaulting to UTC");
|
||||
return "UTC";
|
||||
}
|
||||
return primaryCalendar.timeZone;
|
||||
} catch (error) {
|
||||
this.log.error("Error getting main timezone from Google Calendar", { error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { renewSelectedCalendarCredentialId } from "@calcom/lib/connectedCalendar
|
||||
import { WEBAPP_URL, WEBAPP_URL_FOR_OAUTH } from "@calcom/lib/constants";
|
||||
import { handleErrorsJson } from "@calcom/lib/errors";
|
||||
import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { Prisma } from "@calcom/prisma/client";
|
||||
|
||||
@@ -91,8 +92,21 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
logger.info("Office365 Calendar: Received calendar response", {
|
||||
userId: req.session?.user?.id,
|
||||
status: calRequest.status,
|
||||
statusText: calRequest.statusText,
|
||||
url: calRequest.url,
|
||||
});
|
||||
|
||||
let calBody = await handleErrorsJson<{ value: OfficeCalendar[]; "@odata.nextLink"?: string }>(calRequest);
|
||||
|
||||
logger.info("Office365 Calendar: handleErrorsJson completed", {
|
||||
userId: req.session?.user?.id,
|
||||
calendarCount: calBody.value.length ?? 0,
|
||||
});
|
||||
|
||||
if (typeof responseBody === "string") {
|
||||
calBody = JSON.parse(responseBody) as { value: OfficeCalendar[] };
|
||||
}
|
||||
|
||||
@@ -625,4 +625,21 @@ export default class Office365CalendarService implements Calendar {
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
async getMainTimeZone(): Promise<string> {
|
||||
try {
|
||||
const response = await this.fetcher(`${await this.getUserEndpoint()}/mailboxSettings/timeZone`);
|
||||
const timezone = await handleErrorsJson<string>(response);
|
||||
|
||||
if (!timezone) {
|
||||
this.log.warn("No timezone found in mailbox settings, defaulting to Europe/London");
|
||||
return "Europe/London";
|
||||
}
|
||||
|
||||
return timezone;
|
||||
} catch (error) {
|
||||
this.log.error("Error getting main timezone from Office365 Calendar", { error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { PrismaQueuedFormResponseRepository } from "@calcom/lib/server/repository/routingForm/queuedFormResponse/PrismaQueuedFormResponseRepository";
|
||||
import { QueuedFormResponseService } from "@calcom/lib/server/service/routingForm/queuedFormResponse/QueuedFormResponseService";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
function validateRequest(request: NextRequest) {
|
||||
const apiKey = request.headers.get("authorization") || request.nextUrl.searchParams.get("apiKey");
|
||||
|
||||
if (![process.env.CRON_API_KEY, `Bearer ${process.env.CRON_SECRET}`].includes(`${apiKey}`)) {
|
||||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function handleQueuedFormResponseCleanup(request: NextRequest) {
|
||||
const authError = validateRequest(request);
|
||||
if (authError) {
|
||||
return authError;
|
||||
}
|
||||
|
||||
try {
|
||||
const queuedFormResponseRepo = new PrismaQueuedFormResponseRepository(prisma);
|
||||
const queuedFormResponseService = new QueuedFormResponseService({
|
||||
logger,
|
||||
queuedFormResponseRepo,
|
||||
});
|
||||
|
||||
const result = await queuedFormResponseService.cleanupExpiredResponses({
|
||||
batchSize: 1000,
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
status: "success",
|
||||
data: result,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error during queued form response cleanup:", error);
|
||||
return NextResponse.json(
|
||||
{ status: "error", message: "Failed to cleanup queued form responses" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -79,11 +79,23 @@ export const zoomUserSettingsSchema = z.object({
|
||||
waiting_room: z.boolean(),
|
||||
})
|
||||
.nullish(),
|
||||
meeting_security: z
|
||||
.object({
|
||||
waiting_room_settings: z
|
||||
.object({
|
||||
participants_to_place_in_waiting_room: z.number().optional(),
|
||||
users_who_can_admit_participants_from_waiting_room: z.number().optional(),
|
||||
whitelisted_domains_for_waiting_room: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
.nullish(),
|
||||
});
|
||||
|
||||
// https://developers.zoom.us/docs/api/rest/reference/user/methods/#operation/userSettings
|
||||
// append comma separated settings here, to retrieve only these specific settings
|
||||
const settingsApiFilterResp = "default_password_for_scheduled_meetings,auto_recording,waiting_room";
|
||||
const settingsApiFilterResp =
|
||||
"default_password_for_scheduled_meetings,auto_recording,waiting_room,waiting_room_settings";
|
||||
|
||||
type ZoomRecurrence = {
|
||||
end_date_time?: string;
|
||||
@@ -175,6 +187,12 @@ const ZoomVideoApiAdapter = (credential: CredentialPayload): VideoApiAdapter =>
|
||||
const userSettings = await getUserSettings();
|
||||
const recurrence = getRecurrence(event);
|
||||
const waitingRoomEnabled = userSettings?.in_meeting?.waiting_room ?? false;
|
||||
const advancedWaitingRoomSettings = userSettings?.meeting_security?.waiting_room_settings;
|
||||
const hasAdvancedWaitingRoomSettings =
|
||||
waitingRoomEnabled &&
|
||||
!!advancedWaitingRoomSettings &&
|
||||
typeof advancedWaitingRoomSettings === "object" &&
|
||||
Object.keys(advancedWaitingRoomSettings).length > 0;
|
||||
// Documentation at: https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate
|
||||
return {
|
||||
topic: event.title,
|
||||
@@ -200,6 +218,9 @@ const ZoomVideoApiAdapter = (credential: CredentialPayload): VideoApiAdapter =>
|
||||
enforce_login: false,
|
||||
registrants_email_notification: true,
|
||||
waiting_room: waitingRoomEnabled,
|
||||
...(hasAdvancedWaitingRoomSettings && {
|
||||
waiting_room_settings: advancedWaitingRoomSettings,
|
||||
}),
|
||||
},
|
||||
...recurrence,
|
||||
};
|
||||
|
||||
@@ -33,6 +33,6 @@
|
||||
"prettier-plugin-tailwindcss": "^0.2.5",
|
||||
"tailwind-scrollbar": "^2.0.1",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"typescript": "^5.7.2"
|
||||
"typescript": "^5.9.0-beta"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss": "^8.4.18",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript": "^5.9.0-beta",
|
||||
"vite": "^4.1.2",
|
||||
"vite-plugin-environment": "^1.1.3"
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.resetModules();
|
||||
vi.useRealTimers();
|
||||
vi.clearAllTimers();
|
||||
});
|
||||
|
||||
describe("embedStore.router.ensureQueryParamsInUrl", async () => {
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
"@vitejs/plugin-react": "^2.2.0",
|
||||
"eslint": "^8.34.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript": "^5.9.0-beta",
|
||||
"vite": "^4.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
],
|
||||
"types": "./dist/index.d.ts",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.2",
|
||||
"typescript": "^5.9.0-beta",
|
||||
"vite": "^4.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"@typescript-eslint/parser": "^5.52.0",
|
||||
"@typescript-eslint/utils": "^5.52.0",
|
||||
"ts-node-maintained": "^10.9.5",
|
||||
"typescript": "^5.7.2"
|
||||
"typescript": "^5.9.0-beta"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/eslint": "^8.4.5"
|
||||
|
||||
@@ -5,7 +5,7 @@ const rule = createRule({
|
||||
create(context) {
|
||||
// Track imported names from @calcom/lib/webstorage
|
||||
const safeImportedNames = new Set<string>();
|
||||
|
||||
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
// Check if this is an import from the safe webstorage module
|
||||
@@ -18,11 +18,11 @@ const rule = createRule({
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
CallExpression(node) {
|
||||
const webStorages = ["localStorage", "sessionStorage"];
|
||||
const callee = node.callee;
|
||||
|
||||
|
||||
// Check for window.localStorage or window.sessionStorage
|
||||
if (
|
||||
// Can't figure out how to fix this TS issue
|
||||
@@ -40,7 +40,7 @@ const rule = createRule({
|
||||
messageId: "possible-issue-with-embed",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Check for direct localStorage or sessionStorage usage
|
||||
if (
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
@@ -63,11 +63,11 @@ const rule = createRule({
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Also check for property access like localStorage.length
|
||||
MemberExpression(node) {
|
||||
const webStorages = ["localStorage", "sessionStorage"];
|
||||
|
||||
|
||||
// Check for direct property access on localStorage/sessionStorage
|
||||
if (
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
@@ -86,7 +86,7 @@ const rule = createRule({
|
||||
messageId: "possible-issue-with-embed",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Check for window.localStorage/sessionStorage property access
|
||||
if (
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
@@ -31,6 +31,7 @@ import { isENVDev } from "@calcom/lib/env";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { randomString } from "@calcom/lib/random";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { hashEmail } from "@calcom/lib/server/PiiHasher";
|
||||
import { CredentialRepository } from "@calcom/lib/server/repository/credential";
|
||||
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
|
||||
import { OrganizationRepository } from "@calcom/lib/server/repository/organization";
|
||||
@@ -131,7 +132,7 @@ const providers: Provider[] = [
|
||||
}
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
identifier: user.email,
|
||||
identifier: hashEmail(user.email),
|
||||
});
|
||||
|
||||
if (!user.password?.hash && user.identityProvider !== IdentityProvider.CAL && !credentials.totpCode) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { hashEmail } from "@calcom/lib/server/PiiHasher";
|
||||
|
||||
const log = logger.getSubLogger({ prefix: [`[[Auth] `] });
|
||||
|
||||
@@ -54,7 +55,7 @@ export const sendEmailVerification = async ({
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
rateLimitingType: "core",
|
||||
identifier: email,
|
||||
identifier: hashEmail(email),
|
||||
});
|
||||
|
||||
await prisma.verificationToken.create({
|
||||
@@ -142,7 +143,7 @@ export const sendChangeOfEmailVerification = async ({ user, language }: ChangeOf
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
rateLimitingType: "core",
|
||||
identifier: user.emailFrom,
|
||||
identifier: hashEmail(user.emailFrom),
|
||||
});
|
||||
|
||||
await prisma.verificationToken.create({
|
||||
|
||||
@@ -80,6 +80,7 @@ const BookerComponent = ({
|
||||
confirmButtonDisabled,
|
||||
timeZones,
|
||||
eventMetaChildren,
|
||||
roundRobinHideOrgAndTeam,
|
||||
}: BookerProps & WrappedBookerProps) => {
|
||||
const searchParams = useCompatSearchParams();
|
||||
const isPlatformBookerEmbed = useIsPlatformBookerEmbed();
|
||||
@@ -403,7 +404,8 @@ const BookerComponent = ({
|
||||
isPlatform={isPlatform}
|
||||
isPrivateLink={!!hashedLink}
|
||||
locale={userLocale}
|
||||
timeZones={timeZones}>
|
||||
timeZones={timeZones}
|
||||
roundRobinHideOrgAndTeam={roundRobinHideOrgAndTeam}>
|
||||
{eventMetaChildren}
|
||||
</EventMeta>
|
||||
{layout !== BookerLayouts.MONTH_VIEW &&
|
||||
|
||||
@@ -54,6 +54,7 @@ export const EventMeta = ({
|
||||
locale,
|
||||
timeZones,
|
||||
children,
|
||||
roundRobinHideOrgAndTeam,
|
||||
}: {
|
||||
event?: Pick<
|
||||
BookerEvent,
|
||||
@@ -90,6 +91,7 @@ export const EventMeta = ({
|
||||
locale?: string | null;
|
||||
timeZones?: Timezone[];
|
||||
children?: React.ReactNode;
|
||||
roundRobinHideOrgAndTeam?: boolean;
|
||||
}) => {
|
||||
const { timeFormat, timezone } = useBookerTime();
|
||||
const [setTimezone] = useTimePreferences((state) => [state.setTimezone]);
|
||||
@@ -167,6 +169,7 @@ export const EventMeta = ({
|
||||
profile={event.profile}
|
||||
entity={event.entity}
|
||||
isPrivateLink={isPrivateLink}
|
||||
roundRobinHideOrgAndTeam={roundRobinHideOrgAndTeam}
|
||||
/>
|
||||
<EventTitle className={`${classNames?.eventMetaTitle} my-2`}>
|
||||
{translatedTitle ?? event?.title}
|
||||
|
||||
@@ -140,11 +140,13 @@ export type WrappedBookerPropsForPlatform = WrappedBookerPropsMain & {
|
||||
verifyCode: undefined;
|
||||
customClassNames?: CustomClassNames;
|
||||
timeZones?: Timezone[];
|
||||
roundRobinHideOrgAndTeam?: boolean;
|
||||
};
|
||||
export type WrappedBookerPropsForWeb = WrappedBookerPropsMain & {
|
||||
isPlatform: false;
|
||||
verifyCode: UseVerifyCodeReturnType;
|
||||
timeZones?: Timezone[];
|
||||
roundRobinHideOrgAndTeam?: boolean;
|
||||
};
|
||||
|
||||
export type WrappedBookerProps = WrappedBookerPropsForPlatform | WrappedBookerPropsForWeb;
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface EventMembersProps {
|
||||
profile: BookerEvent["profile"];
|
||||
entity: BookerEvent["entity"];
|
||||
isPrivateLink: boolean;
|
||||
roundRobinHideOrgAndTeam?: boolean;
|
||||
}
|
||||
|
||||
export const EventMembers = ({
|
||||
@@ -26,6 +27,7 @@ export const EventMembers = ({
|
||||
profile,
|
||||
entity,
|
||||
isPrivateLink,
|
||||
roundRobinHideOrgAndTeam,
|
||||
}: EventMembersProps) => {
|
||||
const username = useBookerStore((state) => state.username);
|
||||
const isDynamic = !!(username && username.indexOf("+") > -1);
|
||||
@@ -40,6 +42,10 @@ export const EventMembers = ({
|
||||
!users.length ||
|
||||
(profile.name !== users[0].name && schedulingType === SchedulingType.COLLECTIVE);
|
||||
|
||||
if (schedulingType === SchedulingType.ROUND_ROBIN && roundRobinHideOrgAndTeam) {
|
||||
return <div className="h-6" />;
|
||||
}
|
||||
|
||||
const orgOrTeamAvatarItem =
|
||||
isDynamic || (!profile.image && !entity.logoUrl) || !entity.teamSlug
|
||||
? []
|
||||
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
|
||||
import EventManager, { placeholderCreatedEvent } from "@calcom/lib/EventManager";
|
||||
import { handleAnalyticsEvents } from "@calcom/lib/analyticsManager/handleAnalyticsEvents";
|
||||
import { groupHostsByGroupId } from "@calcom/lib/bookings/hostGroupUtils";
|
||||
import { shouldIgnoreContactOwner } from "@calcom/lib/bookings/routing/utils";
|
||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||
import {
|
||||
@@ -281,9 +282,7 @@ export const buildEventForTeamEventType = async ({
|
||||
const fixedUsers = users.filter((user) => user.isFixed);
|
||||
const nonFixedUsers = users.filter((user) => !user.isFixed);
|
||||
const filteredUsers =
|
||||
schedulingType === SchedulingType.ROUND_ROBIN
|
||||
? [...fixedUsers, ...(nonFixedUsers.length > 0 ? [nonFixedUsers[0]] : [])]
|
||||
: users;
|
||||
schedulingType === SchedulingType.ROUND_ROBIN ? [...fixedUsers, ...nonFixedUsers] : users;
|
||||
|
||||
// Organizer or user owner of this event type it's not listed as a team member.
|
||||
const teamMemberPromises = filteredUsers
|
||||
@@ -387,6 +386,23 @@ export type BookingHandlerInput = {
|
||||
forcedSlug?: string;
|
||||
} & PlatformParams;
|
||||
|
||||
function formatAvailabilitySnapshot(data: {
|
||||
dateRanges: { start: dayjs.Dayjs; end: dayjs.Dayjs }[];
|
||||
oooExcludedDateRanges: { start: dayjs.Dayjs; end: dayjs.Dayjs }[];
|
||||
}) {
|
||||
return {
|
||||
...data,
|
||||
dateRanges: data.dateRanges.map(({ start, end }) => ({
|
||||
start: start.toISOString(),
|
||||
end: end.toISOString(),
|
||||
})),
|
||||
oooExcludedDateRanges: data.oooExcludedDateRanges.map(({ start, end }) => ({
|
||||
start: start.toISOString(),
|
||||
end: end.toISOString(),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
async function handler(
|
||||
input: BookingHandlerInput,
|
||||
bookingDataSchemaGetter: BookingDataSchemaGetter = getBookingDataSchema
|
||||
@@ -808,11 +824,17 @@ async function handler(
|
||||
}
|
||||
}
|
||||
|
||||
const luckyUserPool: IsFixedAwareUser[] = [];
|
||||
const fixedUserPool: IsFixedAwareUser[] = [];
|
||||
const nonFixedUsers: IsFixedAwareUser[] = [];
|
||||
|
||||
availableUsers.forEach((user) => {
|
||||
user.isFixed ? fixedUserPool.push(user) : luckyUserPool.push(user);
|
||||
user.isFixed ? fixedUserPool.push(user) : nonFixedUsers.push(user);
|
||||
});
|
||||
|
||||
// Group non-fixed users by their group IDs
|
||||
const luckyUserPools = groupHostsByGroupId({
|
||||
hosts: nonFixedUsers,
|
||||
hostGroups: eventType.hostGroups,
|
||||
});
|
||||
|
||||
const notAvailableLuckyUsers: typeof users = [];
|
||||
@@ -821,81 +843,88 @@ async function handler(
|
||||
"Computed available users",
|
||||
safeStringify({
|
||||
availableUsers: availableUsers.map((user) => user.id),
|
||||
luckyUserPool: luckyUserPool.map((user) => user.id),
|
||||
luckyUserPools: Object.fromEntries(
|
||||
Object.entries(luckyUserPools).map(([groupId, users]) => [groupId, users.map((user) => user.id)])
|
||||
),
|
||||
})
|
||||
);
|
||||
|
||||
const luckyUsers: typeof users = [];
|
||||
|
||||
// loop through all non-fixed hosts and get the lucky users
|
||||
// This logic doesn't run when contactOwner is used because in that case, luckUsers.length === 1
|
||||
while (luckyUserPool.length > 0 && luckyUsers.length < 1 /* TODO: Add variable */) {
|
||||
const freeUsers = luckyUserPool.filter(
|
||||
(user) => !luckyUsers.concat(notAvailableLuckyUsers).find((existing) => existing.id === user.id)
|
||||
);
|
||||
// no more freeUsers after subtracting notAvailableLuckyUsers from luckyUsers :(
|
||||
if (freeUsers.length === 0) break;
|
||||
assertNonEmptyArray(freeUsers); // make sure TypeScript knows it too with an assertion; the error will never be thrown.
|
||||
// freeUsers is ensured
|
||||
for (const [groupId, luckyUserPool] of Object.entries(luckyUserPools)) {
|
||||
let luckUserFound = false;
|
||||
while (luckyUserPool.length > 0 && !luckUserFound) {
|
||||
const freeUsers = luckyUserPool.filter(
|
||||
(user) => !luckyUsers.concat(notAvailableLuckyUsers).find((existing) => existing.id === user.id)
|
||||
);
|
||||
// no more freeUsers after subtracting notAvailableLuckyUsers from luckyUsers :(
|
||||
if (freeUsers.length === 0) break;
|
||||
assertNonEmptyArray(freeUsers); // make sure TypeScript knows it too with an assertion; the error will never be thrown.
|
||||
// freeUsers is ensured
|
||||
|
||||
const userIdsSet = new Set(users.map((user) => user.id));
|
||||
const firstUserOrgId = await getOrgIdFromMemberOrTeamId({
|
||||
memberId: eventTypeWithUsers.users[0].id ?? null,
|
||||
teamId: eventType.teamId,
|
||||
});
|
||||
const newLuckyUser = await getLuckyUser({
|
||||
// find a lucky user that is not already in the luckyUsers array
|
||||
availableUsers: freeUsers,
|
||||
allRRHosts: (
|
||||
await enrichHostsWithDelegationCredentials({
|
||||
orgId: firstUserOrgId ?? null,
|
||||
hosts: eventTypeWithUsers.hosts,
|
||||
})
|
||||
).filter((host) => !host.isFixed && userIdsSet.has(host.user.id)),
|
||||
eventType,
|
||||
routingFormResponse,
|
||||
meetingStartTime: new Date(reqBody.start),
|
||||
});
|
||||
if (!newLuckyUser) {
|
||||
break; // prevent infinite loop
|
||||
}
|
||||
if (
|
||||
input.bookingData.isFirstRecurringSlot &&
|
||||
eventType.schedulingType === SchedulingType.ROUND_ROBIN
|
||||
) {
|
||||
// for recurring round robin events check if lucky user is available for next slots
|
||||
try {
|
||||
for (
|
||||
let i = 0;
|
||||
i < input.bookingData.allRecurringDates.length &&
|
||||
i < input.bookingData.numSlotsToCheckForAvailability;
|
||||
i++
|
||||
) {
|
||||
const start = input.bookingData.allRecurringDates[i].start;
|
||||
const end = input.bookingData.allRecurringDates[i].end;
|
||||
const userIdsSet = new Set(users.map((user) => user.id));
|
||||
const firstUserOrgId = await getOrgIdFromMemberOrTeamId({
|
||||
memberId: eventTypeWithUsers.users[0].id ?? null,
|
||||
teamId: eventType.teamId,
|
||||
});
|
||||
const newLuckyUser = await getLuckyUser({
|
||||
// find a lucky user that is not already in the luckyUsers array
|
||||
availableUsers: freeUsers,
|
||||
// only hosts from the same group
|
||||
allRRHosts: (
|
||||
await enrichHostsWithDelegationCredentials({
|
||||
orgId: firstUserOrgId ?? null,
|
||||
hosts: eventTypeWithUsers.hosts,
|
||||
})
|
||||
).filter((host) => !host.isFixed && userIdsSet.has(host.user.id) && host.groupId === groupId),
|
||||
eventType,
|
||||
routingFormResponse,
|
||||
meetingStartTime: new Date(reqBody.start),
|
||||
});
|
||||
if (!newLuckyUser) {
|
||||
break; // prevent infinite loop
|
||||
}
|
||||
if (
|
||||
input.bookingData.isFirstRecurringSlot &&
|
||||
eventType.schedulingType === SchedulingType.ROUND_ROBIN
|
||||
) {
|
||||
// for recurring round robin events check if lucky user is available for next slots
|
||||
try {
|
||||
for (
|
||||
let i = 0;
|
||||
i < input.bookingData.allRecurringDates.length &&
|
||||
i < input.bookingData.numSlotsToCheckForAvailability;
|
||||
i++
|
||||
) {
|
||||
const start = input.bookingData.allRecurringDates[i].start;
|
||||
const end = input.bookingData.allRecurringDates[i].end;
|
||||
|
||||
await ensureAvailableUsers(
|
||||
{ ...eventTypeWithUsers, users: [newLuckyUser] },
|
||||
{
|
||||
dateFrom: dayjs(start).tz(reqBody.timeZone).format(),
|
||||
dateTo: dayjs(end).tz(reqBody.timeZone).format(),
|
||||
timeZone: reqBody.timeZone,
|
||||
originalRescheduledBooking,
|
||||
},
|
||||
loggerWithEventDetails,
|
||||
shouldServeCache
|
||||
await ensureAvailableUsers(
|
||||
{ ...eventTypeWithUsers, users: [newLuckyUser] },
|
||||
{
|
||||
dateFrom: dayjs(start).tz(reqBody.timeZone).format(),
|
||||
dateTo: dayjs(end).tz(reqBody.timeZone).format(),
|
||||
timeZone: reqBody.timeZone,
|
||||
originalRescheduledBooking,
|
||||
},
|
||||
loggerWithEventDetails,
|
||||
shouldServeCache
|
||||
);
|
||||
}
|
||||
// if no error, then lucky user is available for the next slots
|
||||
luckyUsers.push(newLuckyUser);
|
||||
luckUserFound = true;
|
||||
} catch {
|
||||
notAvailableLuckyUsers.push(newLuckyUser);
|
||||
loggerWithEventDetails.info(
|
||||
`Round robin host ${newLuckyUser.name} not available for first two slots. Trying to find another host.`
|
||||
);
|
||||
}
|
||||
// if no error, then lucky user is available for the next slots
|
||||
} else {
|
||||
luckyUsers.push(newLuckyUser);
|
||||
} catch {
|
||||
notAvailableLuckyUsers.push(newLuckyUser);
|
||||
loggerWithEventDetails.info(
|
||||
`Round robin host ${newLuckyUser.name} not available for first two slots. Trying to find another host.`
|
||||
);
|
||||
luckUserFound = true;
|
||||
}
|
||||
} else {
|
||||
luckyUsers.push(newLuckyUser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,8 +933,22 @@ async function handler(
|
||||
throw new Error(ErrorCode.FixedHostsUnavailableForBooking);
|
||||
}
|
||||
|
||||
const roundRobinHosts = eventType.hosts.filter((host) => !host.isFixed);
|
||||
|
||||
const hostGroups = groupHostsByGroupId({
|
||||
hosts: roundRobinHosts,
|
||||
hostGroups: eventType.hostGroups,
|
||||
});
|
||||
|
||||
// Filter out host groups that have no hosts in them
|
||||
const nonEmptyHostGroups = Object.fromEntries(
|
||||
Object.entries(hostGroups).filter(([groupId, hosts]) => hosts.length > 0)
|
||||
);
|
||||
// If there are RR hosts, we need to find a lucky user
|
||||
if ([...qualifiedRRUsers, ...additionalFallbackRRUsers].length > 0 && luckyUsers.length === 0) {
|
||||
if (
|
||||
[...qualifiedRRUsers, ...additionalFallbackRRUsers].length > 0 &&
|
||||
luckyUsers.length !== (Object.keys(nonEmptyHostGroups).length || 1)
|
||||
) {
|
||||
throw new Error(ErrorCode.RoundRobinHostsUnavailableForBooking);
|
||||
}
|
||||
|
||||
@@ -916,7 +959,9 @@ async function handler(
|
||||
...troubleshooterData,
|
||||
luckyUsers: luckyUsers.map((u) => u.id),
|
||||
fixedUsers: fixedUserPool.map((u) => u.id),
|
||||
luckyUserPool: luckyUserPool.map((u) => u.id),
|
||||
luckyUserPool: Object.values(luckyUserPools)
|
||||
.flat()
|
||||
.map((u) => u.id),
|
||||
};
|
||||
} else if (
|
||||
input.bookingData.allRecurringDates &&
|
||||
@@ -1397,7 +1442,10 @@ async function handler(
|
||||
|
||||
logger.info(`Booking created`, {
|
||||
bookingUid: booking.uid,
|
||||
availabilitySnapshot: organizerUserAvailability?.availabilityData,
|
||||
selectedCalendarIds: organizerUser.allSelectedCalendars?.map((c) => c.id) ?? [],
|
||||
availabilitySnapshot: organizerUserAvailability?.availabilityData
|
||||
? formatAvailabilitySnapshot(organizerUserAvailability.availabilityData)
|
||||
: null,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import dayjs from "@calcom/dayjs";
|
||||
import type { Dayjs } from "@calcom/dayjs";
|
||||
import { checkForConflicts } from "@calcom/features/bookings/lib/conflictChecker/checkForConflicts";
|
||||
import { buildDateRanges } from "@calcom/lib/date-ranges";
|
||||
import { getBusyTimesService } from "@calcom/lib/di/containers/busy-times";
|
||||
import { getUserAvailabilityService } from "@calcom/lib/di/containers/get-user-availability";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { getBusyTimesForLimitChecks } from "@calcom/lib/getBusyTimes";
|
||||
import { getUsersAvailability } from "@calcom/lib/getUserAvailability";
|
||||
import { parseBookingLimit } from "@calcom/lib/intervalLimits/isBookingLimits";
|
||||
import { parseDurationLimit } from "@calcom/lib/intervalLimits/isDurationLimits";
|
||||
import { getPiiFreeUser } from "@calcom/lib/piiFreeData";
|
||||
@@ -62,6 +62,7 @@ const _ensureAvailableUsers = async (
|
||||
shouldServeCache?: boolean
|
||||
// ReturnType hint of at least one IsFixedAwareUser, as it's made sure at least one entry exists
|
||||
): Promise<[IsFixedAwareUser, ...IsFixedAwareUser[]]> => {
|
||||
const userAvailabilityService = getUserAvailabilityService();
|
||||
const availableUsers: IsFixedAwareUser[] = [];
|
||||
|
||||
const startDateTimeUtc = getDateTimeInUtc(input.dateFrom, input.timeZone);
|
||||
@@ -73,9 +74,12 @@ const _ensureAvailableUsers = async (
|
||||
const bookingLimits = parseBookingLimit(eventType?.bookingLimits);
|
||||
const durationLimits = parseDurationLimit(eventType?.durationLimits);
|
||||
|
||||
const busyTimesFromLimitsBookingsAllUsers: Awaited<ReturnType<typeof getBusyTimesForLimitChecks>> =
|
||||
const busyTimesService = getBusyTimesService();
|
||||
const busyTimesFromLimitsBookingsAllUsers: Awaited<
|
||||
ReturnType<typeof busyTimesService.getBusyTimesForLimitChecks>
|
||||
> =
|
||||
eventType && (bookingLimits || durationLimits)
|
||||
? await getBusyTimesForLimitChecks({
|
||||
? await busyTimesService.getBusyTimesForLimitChecks({
|
||||
userIds: eventType.users.map((u) => u.id),
|
||||
eventTypeId: eventType.id,
|
||||
startDate: startDateTimeUtc.format(),
|
||||
@@ -86,7 +90,7 @@ const _ensureAvailableUsers = async (
|
||||
})
|
||||
: [];
|
||||
|
||||
const usersAvailability = await getUsersAvailability({
|
||||
const usersAvailability = await userAvailabilityService.getUsersAvailability({
|
||||
users: eventType.users,
|
||||
query: {
|
||||
...input,
|
||||
|
||||
@@ -135,6 +135,7 @@ export const getEventTypesFromDB = async (eventTypeId: number) => {
|
||||
priority: true,
|
||||
weight: true,
|
||||
createdAt: true,
|
||||
groupId: true,
|
||||
user: {
|
||||
select: {
|
||||
credentials: {
|
||||
@@ -177,6 +178,12 @@ export const getEventTypesFromDB = async (eventTypeId: number) => {
|
||||
assignRRMembersUsingSegment: true,
|
||||
rrSegmentQueryValue: true,
|
||||
useEventLevelSelectedCalendars: true,
|
||||
hostGroups: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -206,6 +213,7 @@ export const getEventTypesFromDB = async (eventTypeId: number) => {
|
||||
bookingFields: getBookingFieldsWithSystemFields({ ...restEventType, isOrgTeamEvent }),
|
||||
rrSegmentQueryValue: rrSegmentQueryValueSchema.parse(eventType.rrSegmentQueryValue) ?? null,
|
||||
isDynamic: false,
|
||||
hostGroups: eventType.hostGroups || [],
|
||||
};
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes("Record to update not found")) {
|
||||
|
||||
@@ -85,12 +85,13 @@ const loadUsersByEventType = async (eventType: EventType): Promise<NewBookingEve
|
||||
eventType,
|
||||
hosts: hosts ?? fallbackHosts,
|
||||
});
|
||||
return matchingHosts.map(({ user, isFixed, priority, weight, createdAt }) => ({
|
||||
return matchingHosts.map(({ user, isFixed, priority, weight, createdAt, groupId }) => ({
|
||||
...user,
|
||||
isFixed,
|
||||
priority,
|
||||
weight,
|
||||
createdAt,
|
||||
groupId,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
+302
@@ -0,0 +1,302 @@
|
||||
import type { Booking, User, Webhook } from "@prisma/client";
|
||||
import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
|
||||
|
||||
import { DailyLocationType } from "@calcom/app-store/locations";
|
||||
import { getMeetingSessionsFromRoomName } from "@calcom/features/tasker/tasks/triggerNoShow/getMeetingSessionsFromRoomName";
|
||||
import { triggerHostNoShow } from "@calcom/features/tasker/tasks/triggerNoShow/triggerHostNoShow";
|
||||
import { sendGenericWebhookPayload } from "@calcom/features/webhooks/lib/sendPayload";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { TimeUnit, WebhookTriggerEvents } from "@calcom/prisma/enums";
|
||||
|
||||
import { scheduleNoShowTriggers } from "./scheduleNoShowTriggers";
|
||||
|
||||
vi.mock("@calcom/features/tasker/tasks/triggerNoShow/getMeetingSessionsFromRoomName", () => ({
|
||||
getMeetingSessionsFromRoomName: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@calcom/features/webhooks/lib/sendPayload", () => ({
|
||||
sendGenericWebhookPayload: vi.fn().mockResolvedValue({}),
|
||||
}));
|
||||
|
||||
describe("scheduleNoShowTriggers Integration", () => {
|
||||
let testUser: User;
|
||||
let hostWebhook: Webhook;
|
||||
let guestWebhook: Webhook;
|
||||
const testEventTypeId = 67890;
|
||||
const testBookingIds = [98765, 98766];
|
||||
const testBookingId = 123456;
|
||||
|
||||
beforeAll(async () => {
|
||||
testUser = await prisma.user.create({
|
||||
data: {
|
||||
email: "test-user-no-show@example.com",
|
||||
username: "test-user-no-show",
|
||||
name: "Test User No Show",
|
||||
},
|
||||
});
|
||||
|
||||
[hostWebhook, guestWebhook] = await Promise.all([
|
||||
prisma.webhook.create({
|
||||
data: {
|
||||
id: "test-host-webhook-id",
|
||||
userId: testUser.id,
|
||||
subscriberUrl: "https://example.com/host-webhook",
|
||||
eventTriggers: [WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW],
|
||||
active: true,
|
||||
time: 5,
|
||||
timeUnit: TimeUnit.MINUTE,
|
||||
},
|
||||
}),
|
||||
prisma.webhook.create({
|
||||
data: {
|
||||
id: "test-guest-webhook-id",
|
||||
userId: testUser.id,
|
||||
subscriberUrl: "https://example.com/guest-webhook",
|
||||
eventTriggers: [WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW],
|
||||
active: true,
|
||||
time: 10,
|
||||
timeUnit: TimeUnit.MINUTE,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await prisma.task.deleteMany({
|
||||
where: {
|
||||
OR: [{ type: "triggerHostNoShowWebhook" }, { type: "triggerGuestNoShowWebhook" }],
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.webhook.deleteMany({
|
||||
where: {
|
||||
userId: testUser.id,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.booking.deleteMany({
|
||||
where: {
|
||||
id: testBookingId,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.user.deleteMany({
|
||||
where: {
|
||||
id: testUser.id,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.eventType.deleteMany({
|
||||
where: {
|
||||
id: testEventTypeId,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("scheduling a webhook creates the correct Tasker jobs for no-show webhooks", async () => {
|
||||
const currentDate = new Date("2023-01-01T10:00:00.000Z");
|
||||
const bookingData: Partial<Booking> & { startTime: Date; id: number; location: string } = {
|
||||
id: testBookingIds[0],
|
||||
startTime: currentDate,
|
||||
endTime: new Date("2023-01-01T10:30:00.000Z"),
|
||||
location: DailyLocationType,
|
||||
};
|
||||
|
||||
await scheduleNoShowTriggers({
|
||||
booking: bookingData,
|
||||
organizerUser: { id: testUser.id },
|
||||
eventTypeId: testEventTypeId,
|
||||
triggerForUser: true,
|
||||
});
|
||||
|
||||
const createdTasks = await prisma.task.findMany({
|
||||
where: {
|
||||
OR: [{ type: "triggerHostNoShowWebhook" }, { type: "triggerGuestNoShowWebhook" }],
|
||||
},
|
||||
});
|
||||
|
||||
expect(createdTasks.length).toBe(2);
|
||||
|
||||
const hostTask = createdTasks.find((task) => task.type === "triggerHostNoShowWebhook");
|
||||
expect(hostTask).toBeDefined();
|
||||
|
||||
const guestTask = createdTasks.find((task) => task.type === "triggerGuestNoShowWebhook");
|
||||
expect(guestTask).toBeDefined();
|
||||
});
|
||||
|
||||
test("created task payloads for no-show webhooks are correct", async () => {
|
||||
const currentDate = new Date("2023-01-01T11:00:00.000Z");
|
||||
const bookingData: Partial<Booking> & { startTime: Date; id: number; location: string } = {
|
||||
id: testBookingIds[1],
|
||||
startTime: currentDate,
|
||||
endTime: new Date("2023-01-01T11:30:00.000Z"),
|
||||
location: DailyLocationType,
|
||||
};
|
||||
|
||||
await scheduleNoShowTriggers({
|
||||
booking: bookingData,
|
||||
organizerUser: { id: testUser.id },
|
||||
eventTypeId: testEventTypeId,
|
||||
triggerForUser: true,
|
||||
});
|
||||
|
||||
const createdTasks = await prisma.task.findMany({
|
||||
where: {
|
||||
OR: [{ type: "triggerHostNoShowWebhook" }, { type: "triggerGuestNoShowWebhook" }],
|
||||
payload: {
|
||||
contains: bookingData.id.toString(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const hostTask = createdTasks.find((task) => task.type === "triggerHostNoShowWebhook");
|
||||
expect(hostTask).toBeDefined();
|
||||
|
||||
let hostPayload;
|
||||
try {
|
||||
hostPayload = JSON.parse(hostTask?.payload ?? "");
|
||||
} catch (e) {
|
||||
console.error("Failed to parse host task payload.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(hostPayload).toEqual({
|
||||
triggerEvent: WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW,
|
||||
bookingId: bookingData.id,
|
||||
webhook: expect.objectContaining({
|
||||
id: hostWebhook.id,
|
||||
subscriberUrl: "https://example.com/host-webhook",
|
||||
eventTriggers: [WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW],
|
||||
time: 5,
|
||||
timeUnit: TimeUnit.MINUTE,
|
||||
}),
|
||||
});
|
||||
|
||||
const guestTask = createdTasks.find((task) => task.type === "triggerGuestNoShowWebhook");
|
||||
expect(guestTask).toBeDefined();
|
||||
|
||||
let guestPayload;
|
||||
try {
|
||||
guestPayload = JSON.parse(guestTask?.payload ?? "");
|
||||
} catch (e) {
|
||||
console.error("Failed to parse guest task payload.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(guestPayload).toEqual({
|
||||
triggerEvent: WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW,
|
||||
bookingId: bookingData.id,
|
||||
webhook: expect.objectContaining({
|
||||
id: guestWebhook.id,
|
||||
subscriberUrl: "https://example.com/guest-webhook",
|
||||
eventTriggers: [WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW],
|
||||
time: 10,
|
||||
timeUnit: TimeUnit.MINUTE,
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
test("task handler runs properly with the correct payload", async () => {
|
||||
await prisma.eventType.create({
|
||||
data: {
|
||||
id: testEventTypeId,
|
||||
title: "Test Event Type",
|
||||
slug: "test-event-type",
|
||||
length: 30,
|
||||
userId: testUser.id,
|
||||
description: "Test description",
|
||||
},
|
||||
});
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await prisma.booking.create({
|
||||
data: {
|
||||
id: testBookingId,
|
||||
uid: "test-uid-no-show",
|
||||
title: "Test No-Show",
|
||||
eventTypeId: testEventTypeId,
|
||||
status: "ACCEPTED",
|
||||
startTime: now,
|
||||
endTime: new Date(now.getTime() + 30 * 60 * 1000),
|
||||
location: DailyLocationType,
|
||||
userId: testUser.id,
|
||||
references: {
|
||||
create: {
|
||||
type: "daily_video",
|
||||
uid: "meeting-test-uid",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
vi.mocked(getMeetingSessionsFromRoomName).mockResolvedValue({
|
||||
total_count: 1,
|
||||
data: [
|
||||
{
|
||||
id: "meeting-test-id",
|
||||
room: "meeting-test-uid",
|
||||
start_time: Math.floor(now.getTime() / 1000),
|
||||
duration: 30,
|
||||
max_participants: 1,
|
||||
participants: [
|
||||
{
|
||||
user_id: "999999",
|
||||
participant_id: "participant-test-id",
|
||||
user_name: "Guest User",
|
||||
join_time: Math.floor(now.getTime() / 1000),
|
||||
duration: 30,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const taskPayload = JSON.stringify({
|
||||
triggerEvent: WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW,
|
||||
bookingId: testBookingId,
|
||||
webhook: {
|
||||
id: hostWebhook.id,
|
||||
subscriberUrl: "https://example.com/host-webhook",
|
||||
eventTriggers: [WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW],
|
||||
active: true,
|
||||
time: 5,
|
||||
timeUnit: TimeUnit.MINUTE,
|
||||
payloadTemplate: null,
|
||||
secret: null,
|
||||
appId: null,
|
||||
},
|
||||
});
|
||||
|
||||
await triggerHostNoShow(taskPayload);
|
||||
|
||||
expect(sendGenericWebhookPayload).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
webhook: expect.objectContaining({
|
||||
id: hostWebhook.id,
|
||||
subscriberUrl: "https://example.com/host-webhook",
|
||||
}),
|
||||
triggerEvent: WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW,
|
||||
data: expect.objectContaining({
|
||||
bookingId: testBookingId,
|
||||
bookingUid: "test-uid-no-show",
|
||||
message: expect.stringContaining("Host with email"),
|
||||
participants: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
user_id: "999999",
|
||||
user_name: "Guest User",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
const updatedBooking = await prisma.booking.findUnique({
|
||||
where: {
|
||||
id: testBookingId,
|
||||
},
|
||||
});
|
||||
|
||||
expect(updatedBooking?.noShowHost).toBe(true);
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -139,7 +139,7 @@ describe("buildEventForTeamEventType", () => {
|
||||
|
||||
expect(memberEmails).toContain("fixed@example.com");
|
||||
expect(memberEmails).toContain("nonfixed1@example.com");
|
||||
expect(memberEmails).not.toContain("nonfixed2@example.com");
|
||||
expect(memberEmails).toContain("nonfixed2@example.com");
|
||||
});
|
||||
|
||||
it("builds a team with fallback name and id", async () => {
|
||||
|
||||
+652
@@ -0,0 +1,652 @@
|
||||
import {
|
||||
getBooker,
|
||||
TestData,
|
||||
getOrganizer,
|
||||
createBookingScenario,
|
||||
Timezones,
|
||||
getScenarioData,
|
||||
mockSuccessfulVideoMeetingCreation,
|
||||
BookingLocations,
|
||||
getDate,
|
||||
getMockBookingAttendee,
|
||||
getGoogleCalendarCredential,
|
||||
mockCalendarToHaveNoBusySlots,
|
||||
} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
||||
import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
|
||||
import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
|
||||
|
||||
import { describe, test, vi, expect } from "vitest";
|
||||
|
||||
import { appStoreMetadata } from "@calcom/app-store/apps.metadata.generated";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { SchedulingType } from "@calcom/prisma/enums";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
|
||||
describe("Round Robin handleNewBooking", () => {
|
||||
setupAndTeardown();
|
||||
|
||||
describe("Round Robin with groups", () => {
|
||||
test("Books one host from each round robin group", async () => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
const booker = getBooker({
|
||||
email: "booker@example.com",
|
||||
name: "Booker",
|
||||
});
|
||||
const teamMemberOne = [
|
||||
{
|
||||
name: "Team Member One",
|
||||
username: "other-team-member-1",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-one@example.com",
|
||||
id: 102,
|
||||
schedule: TestData.schedules.IstMorningShift,
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
destinationCalendar: {
|
||||
integration: TestData.apps["google-calendar"].type,
|
||||
externalId: "other-team-member-1@google-calendar.com",
|
||||
},
|
||||
},
|
||||
];
|
||||
const organizer = getOrganizer({
|
||||
name: "Organizer",
|
||||
email: "organizer@example.com",
|
||||
id: 101,
|
||||
defaultScheduleId: null,
|
||||
schedules: [TestData.schedules.IstMorningShift],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
destinationCalendar: {
|
||||
integration: TestData.apps["google-calendar"].type,
|
||||
externalId: "organizer@google-calendar.com",
|
||||
},
|
||||
});
|
||||
|
||||
const teamMembers = [
|
||||
{
|
||||
name: "Team Member 1",
|
||||
username: "team-member-1",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-1@example.com",
|
||||
id: 102,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 2",
|
||||
username: "team-member-2",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-2@example.com",
|
||||
id: 103,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 3",
|
||||
username: "team-member-3",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-3@example.com",
|
||||
id: 104,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 4",
|
||||
username: "team-member-4",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-4@example.com",
|
||||
id: 105,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
];
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slotInterval: 15,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
length: 15,
|
||||
users: [
|
||||
{ id: teamMembers[0].id },
|
||||
{ id: teamMembers[1].id },
|
||||
{ id: teamMembers[2].id },
|
||||
{ id: teamMembers[3].id },
|
||||
],
|
||||
hosts: [
|
||||
{ userId: teamMembers[0].id, isFixed: false, groupId: "group-1" },
|
||||
{ userId: teamMembers[1].id, isFixed: false, groupId: "group-1" },
|
||||
{ userId: teamMembers[2].id, isFixed: false, groupId: "group-2" },
|
||||
{ userId: teamMembers[3].id, isFixed: false, groupId: "group-2" },
|
||||
],
|
||||
hostGroups: [
|
||||
{ id: "group-1", name: "Group 1" },
|
||||
{ id: "group-2", name: "Group 2" },
|
||||
],
|
||||
schedule: TestData.schedules.IstMorningShift,
|
||||
destinationCalendar: {
|
||||
integration: TestData.apps["google-calendar"].type,
|
||||
externalId: "event-type-1@google-calendar.com",
|
||||
},
|
||||
},
|
||||
],
|
||||
organizer,
|
||||
usersApartFromOrganizer: teamMembers,
|
||||
apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]],
|
||||
})
|
||||
);
|
||||
|
||||
mockSuccessfulVideoMeetingCreation({
|
||||
metadataLookupKey: appStoreMetadata.dailyvideo.dirName,
|
||||
videoMeetingData: {
|
||||
id: "MOCK_ID",
|
||||
password: "MOCK_PASS",
|
||||
url: `http://mock-dailyvideo.example.com/meeting-1`,
|
||||
},
|
||||
});
|
||||
const calendarMock = mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID",
|
||||
iCalUID: "MOCKED_GOOGLE_CALENDAR_ICS_ID",
|
||||
},
|
||||
});
|
||||
const mockBookingData = getMockRequestDataForBooking({
|
||||
data: {
|
||||
// Try booking the first available free timeslot in both the users' schedules
|
||||
start: `${getDate({ dateIncrement: 1 }).dateString}T11:30:00.000Z`,
|
||||
end: `${getDate({ dateIncrement: 1 }).dateString}T11:45:00.000Z`,
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
},
|
||||
});
|
||||
const createdBooking = await handleNewBooking({
|
||||
bookingData: mockBookingData,
|
||||
});
|
||||
|
||||
// Verify that the booking was created successfully
|
||||
expect(createdBooking).toBeDefined();
|
||||
expect(createdBooking.responses).toEqual(
|
||||
expect.objectContaining({
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
})
|
||||
);
|
||||
|
||||
// Verify that lucky users were selected (one from each group)
|
||||
expect(createdBooking.luckyUsers).toBeDefined();
|
||||
expect(createdBooking.luckyUsers).toHaveLength(2);
|
||||
|
||||
// Verify that the selected users are from different groups
|
||||
const selectedUserIds = createdBooking.luckyUsers;
|
||||
const group1UserIds = [teamMembers[0].id, teamMembers[1].id]; // group-1
|
||||
const group2UserIds = [teamMembers[2].id, teamMembers[3].id]; // group-2
|
||||
|
||||
// Check that one user is from group-1 and one is from group-2
|
||||
const hasGroup1User = selectedUserIds.some((id) => group1UserIds.includes(id));
|
||||
const hasGroup2User = selectedUserIds.some((id) => group2UserIds.includes(id));
|
||||
|
||||
expect(hasGroup1User).toBe(true);
|
||||
expect(hasGroup2User).toBe(true);
|
||||
|
||||
// Verify that the booking has the correct attendees
|
||||
expect(createdBooking.attendees).toHaveLength(2);
|
||||
expect(createdBooking.attendees[0].email).toBe(booker.email);
|
||||
|
||||
// The second attendee should be one of the selected lucky users
|
||||
const secondAttendeeEmail = createdBooking.attendees[1].email;
|
||||
const selectedUserEmails = selectedUserIds.map(
|
||||
(id) => teamMembers.find((member) => member.id === id)?.email
|
||||
);
|
||||
expect(selectedUserEmails).toContain(secondAttendeeEmail);
|
||||
});
|
||||
|
||||
test("Throws error when one round robin group has no available hosts", async () => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
const booker = getBooker({
|
||||
email: "booker@example.com",
|
||||
name: "Booker",
|
||||
});
|
||||
|
||||
const teamMembers = [
|
||||
{
|
||||
name: "Team Member 1",
|
||||
username: "team-member-1",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-1@example.com",
|
||||
id: 102,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 2",
|
||||
username: "team-member-2",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-2@example.com",
|
||||
id: 103,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 3",
|
||||
username: "team-member-3",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-3@example.com",
|
||||
id: 104,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 4",
|
||||
username: "team-member-4",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-4@example.com",
|
||||
id: 105,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
];
|
||||
|
||||
const organizer = getOrganizer({
|
||||
name: "Organizer",
|
||||
email: "organizer@example.com",
|
||||
id: 101,
|
||||
defaultScheduleId: null,
|
||||
schedules: [TestData.schedules.IstMorningShift],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
destinationCalendar: {
|
||||
integration: TestData.apps["google-calendar"].type,
|
||||
externalId: "organizer@google-calendar.com",
|
||||
},
|
||||
});
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slotInterval: 15,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
length: 15,
|
||||
users: [
|
||||
{ id: teamMembers[0].id },
|
||||
{ id: teamMembers[1].id },
|
||||
{ id: teamMembers[2].id },
|
||||
{ id: teamMembers[3].id },
|
||||
],
|
||||
hosts: [
|
||||
{ userId: teamMembers[0].id, isFixed: false, groupId: "group-1" },
|
||||
{ userId: teamMembers[1].id, isFixed: false, groupId: "group-1" },
|
||||
{ userId: teamMembers[2].id, isFixed: false, groupId: "group-2" },
|
||||
{ userId: teamMembers[3].id, isFixed: false, groupId: "group-2" },
|
||||
],
|
||||
hostGroups: [
|
||||
{ id: "group-1", name: "Group 1" },
|
||||
{ id: "group-2", name: "Group 2" },
|
||||
],
|
||||
schedule: TestData.schedules.IstMorningShift,
|
||||
destinationCalendar: {
|
||||
integration: TestData.apps["google-calendar"].type,
|
||||
externalId: "event-type-1@google-calendar.com",
|
||||
},
|
||||
},
|
||||
],
|
||||
organizer,
|
||||
usersApartFromOrganizer: teamMembers,
|
||||
apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]],
|
||||
// Add existing bookings to make only group-2 hosts busy
|
||||
bookings: [
|
||||
{
|
||||
userId: teamMembers[0].id, // Team Member 1 (group-1)
|
||||
eventTypeId: 1,
|
||||
startTime: `${getDate({ dateIncrement: 1 }).dateString}T11:30:00.000Z`,
|
||||
endTime: `${getDate({ dateIncrement: 1 }).dateString}T11:45:00.000Z`,
|
||||
status: "ACCEPTED",
|
||||
attendees: [
|
||||
{
|
||||
email: "existing-booker-1@example.com",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
userId: teamMembers[1].id, // Team Member 2 (group-1)
|
||||
eventTypeId: 1,
|
||||
startTime: `${getDate({ dateIncrement: 1 }).dateString}T11:30:00.000Z`,
|
||||
endTime: `${getDate({ dateIncrement: 1 }).dateString}T11:45:00.000Z`,
|
||||
status: "ACCEPTED",
|
||||
attendees: [
|
||||
{
|
||||
email: "existing-booker-2@example.com",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
mockSuccessfulVideoMeetingCreation({
|
||||
metadataLookupKey: appStoreMetadata.dailyvideo.dirName || "dailyvideo",
|
||||
videoMeetingData: {
|
||||
id: "MOCK_ID",
|
||||
password: "MOCK_PASS",
|
||||
url: `http://mock-dailyvideo.example.com/meeting-1`,
|
||||
},
|
||||
});
|
||||
|
||||
const calendarMock = mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID",
|
||||
iCalUID: "MOCKED_GOOGLE_CALENDAR_ICS_ID",
|
||||
},
|
||||
});
|
||||
|
||||
const mockBookingData = getMockRequestDataForBooking({
|
||||
data: {
|
||||
start: `${getDate({ dateIncrement: 1 }).dateString}T11:30:00.000Z`,
|
||||
end: `${getDate({ dateIncrement: 1 }).dateString}T11:45:00.000Z`,
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Expect handleNewBooking to throw an error because group-2 has no available hosts
|
||||
await expect(
|
||||
handleNewBooking({
|
||||
bookingData: mockBookingData,
|
||||
})
|
||||
).rejects.toThrow(ErrorCode.RoundRobinHostsUnavailableForBooking);
|
||||
});
|
||||
|
||||
test("Creates successful booking even when one group has no hosts", async () => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
const booker = getBooker({
|
||||
email: "booker@example.com",
|
||||
name: "Booker",
|
||||
});
|
||||
|
||||
const teamMembers = [
|
||||
{
|
||||
name: "Team Member 1",
|
||||
username: "team-member-1",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-1@example.com",
|
||||
id: 102,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 2",
|
||||
username: "team-member-2",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-2@example.com",
|
||||
id: 103,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
];
|
||||
|
||||
const organizer = getOrganizer({
|
||||
name: "Organizer",
|
||||
email: "organizer@example.com",
|
||||
id: 101,
|
||||
defaultScheduleId: null,
|
||||
schedules: [TestData.schedules.IstMorningShift],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
destinationCalendar: {
|
||||
integration: TestData.apps["google-calendar"].type,
|
||||
externalId: "organizer@google-calendar.com",
|
||||
},
|
||||
});
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slotInterval: 15,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
length: 15,
|
||||
users: [{ id: teamMembers[0].id }, { id: teamMembers[1].id }],
|
||||
hosts: [
|
||||
{ userId: teamMembers[0].id, isFixed: false, groupId: "group-1" },
|
||||
{ userId: teamMembers[1].id, isFixed: false, groupId: "group-1" },
|
||||
],
|
||||
hostGroups: [
|
||||
{ id: "group-1", name: "Group 1" },
|
||||
{ id: "group-2", name: "Group 2" }, // Empty group with no hosts
|
||||
],
|
||||
schedule: TestData.schedules.IstMorningShift,
|
||||
destinationCalendar: {
|
||||
integration: TestData.apps["google-calendar"].type,
|
||||
externalId: "event-type-1@google-calendar.com",
|
||||
},
|
||||
},
|
||||
],
|
||||
organizer,
|
||||
usersApartFromOrganizer: teamMembers,
|
||||
apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]],
|
||||
})
|
||||
);
|
||||
|
||||
mockSuccessfulVideoMeetingCreation({
|
||||
metadataLookupKey: appStoreMetadata.dailyvideo.dirName,
|
||||
videoMeetingData: {
|
||||
id: "MOCK_ID",
|
||||
password: "MOCK_PASS",
|
||||
url: `http://mock-dailyvideo.example.com/meeting-1`,
|
||||
},
|
||||
});
|
||||
|
||||
const calendarMock = mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID",
|
||||
iCalUID: "MOCKED_GOOGLE_CALENDAR_ICS_ID",
|
||||
},
|
||||
});
|
||||
|
||||
const mockBookingData = getMockRequestDataForBooking({
|
||||
data: {
|
||||
start: `${getDate({ dateIncrement: 1 }).dateString}T11:30:00.000Z`,
|
||||
end: `${getDate({ dateIncrement: 1 }).dateString}T11:45:00.000Z`,
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const createdBooking = await handleNewBooking({
|
||||
bookingData: mockBookingData,
|
||||
});
|
||||
|
||||
// Verify that the booking was created successfully
|
||||
expect(createdBooking).toBeDefined();
|
||||
expect(createdBooking.responses).toEqual(
|
||||
expect.objectContaining({
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
})
|
||||
);
|
||||
|
||||
// Verify that lucky users were selected (only from group-1 since group-2 has no hosts)
|
||||
expect(createdBooking.luckyUsers).toBeDefined();
|
||||
expect(createdBooking.luckyUsers).toHaveLength(1);
|
||||
|
||||
// Verify that the selected user is from group-1
|
||||
const selectedUserId = createdBooking.luckyUsers[0];
|
||||
const group1UserIds = [teamMembers[0].id, teamMembers[1].id]; // group-1
|
||||
expect(group1UserIds).toContain(selectedUserId);
|
||||
|
||||
// Verify that the booking has the correct attendees
|
||||
expect(createdBooking.attendees).toHaveLength(1);
|
||||
expect(createdBooking.attendees[0].email).toBe(booker.email);
|
||||
|
||||
// Verify that the booking user is the selected lucky user
|
||||
expect(createdBooking.userId).toBe(selectedUserId);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Seated Round Robin Event", () => {
|
||||
test("For second seat booking, organizer remains the same with no team members included", async () => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
const EventManager = (await import("@calcom/lib/EventManager")).default;
|
||||
|
||||
const eventManagerSpy = vi.spyOn(EventManager.prototype, "updateCalendarAttendees");
|
||||
|
||||
const booker = getBooker({
|
||||
email: "seat2@example.com",
|
||||
name: "Seat 2",
|
||||
});
|
||||
|
||||
const assignedHost = getOrganizer({
|
||||
name: "Assigned Host",
|
||||
email: "assigned-host@example.com",
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
});
|
||||
|
||||
const teamMembers = [
|
||||
{
|
||||
name: "Team Member 1",
|
||||
username: "team-member-1",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-1@example.com",
|
||||
id: 102,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 2",
|
||||
username: "team-member-2",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-2@example.com",
|
||||
id: 103,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
];
|
||||
|
||||
const bookingId = 1;
|
||||
const bookingUid = "abc123";
|
||||
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
||||
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
|
||||
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slug: "seated-round-robin-event",
|
||||
slotInterval: 30,
|
||||
length: 30,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
users: [{ id: assignedHost.id }, { id: teamMembers[0].id }, { id: teamMembers[1].id }],
|
||||
hosts: [
|
||||
{ userId: assignedHost.id, isFixed: false },
|
||||
{ userId: teamMembers[0].id, isFixed: false },
|
||||
{ userId: teamMembers[1].id, isFixed: false },
|
||||
],
|
||||
seatsPerTimeSlot: 3,
|
||||
seatsShowAttendees: false,
|
||||
},
|
||||
],
|
||||
bookings: [
|
||||
{
|
||||
id: bookingId,
|
||||
uid: bookingUid,
|
||||
eventTypeId: 1,
|
||||
status: BookingStatus.ACCEPTED,
|
||||
startTime: bookingStartTime,
|
||||
endTime: bookingEndTime,
|
||||
userId: assignedHost.id, // This is the assigned host for the booking
|
||||
metadata: {
|
||||
videoCallUrl: "https://existing-daily-video-call-url.example.com",
|
||||
},
|
||||
references: [
|
||||
{
|
||||
type: appStoreMetadata.dailyvideo.type,
|
||||
uid: "MOCK_ID",
|
||||
meetingId: "MOCK_ID",
|
||||
meetingPassword: "MOCK_PASS",
|
||||
meetingUrl: "http://mock-dailyvideo.example.com",
|
||||
credentialId: null,
|
||||
},
|
||||
],
|
||||
attendees: [
|
||||
getMockBookingAttendee({
|
||||
id: 1,
|
||||
name: "Seat 1",
|
||||
email: "seat1@test.com",
|
||||
locale: "en",
|
||||
timeZone: "America/Toronto",
|
||||
bookingSeat: {
|
||||
referenceUid: "booking-seat-1",
|
||||
data: {},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
organizer: assignedHost,
|
||||
usersApartFromOrganizer: [...teamMembers],
|
||||
})
|
||||
);
|
||||
|
||||
mockSuccessfulVideoMeetingCreation({
|
||||
metadataLookupKey: "dailyvideo",
|
||||
videoMeetingData: {
|
||||
id: "MOCK_ID",
|
||||
password: "MOCK_PASS",
|
||||
url: `http://mock-dailyvideo.example.com/meeting-1`,
|
||||
},
|
||||
});
|
||||
|
||||
const reqBookingUser = "seatedAttendee";
|
||||
|
||||
const mockBookingData = getMockRequestDataForBooking({
|
||||
data: {
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
bookingUid: bookingUid,
|
||||
user: reqBookingUser,
|
||||
},
|
||||
});
|
||||
|
||||
await handleNewBooking({
|
||||
bookingData: mockBookingData,
|
||||
});
|
||||
|
||||
expect(eventManagerSpy).toHaveBeenCalled();
|
||||
|
||||
const calendarEvent = eventManagerSpy.mock.calls[0][0];
|
||||
|
||||
expect(calendarEvent.organizer.email).toBe(assignedHost.email);
|
||||
|
||||
expect(calendarEvent.team?.members).toBeDefined();
|
||||
expect(calendarEvent.team?.members.length).toBe(0);
|
||||
|
||||
const teamMemberEmails = calendarEvent.team?.members.map((member) => member.email);
|
||||
expect(teamMemberEmails).not.toContain(teamMembers[0].email);
|
||||
expect(teamMemberEmails).not.toContain(teamMembers[1].email);
|
||||
});
|
||||
});
|
||||
});
|
||||
-172
@@ -1,172 +0,0 @@
|
||||
import {
|
||||
getBooker,
|
||||
TestData,
|
||||
getOrganizer,
|
||||
createBookingScenario,
|
||||
Timezones,
|
||||
getScenarioData,
|
||||
mockSuccessfulVideoMeetingCreation,
|
||||
BookingLocations,
|
||||
getDate,
|
||||
getMockBookingAttendee,
|
||||
} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
||||
import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking";
|
||||
import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown";
|
||||
|
||||
import { describe, test, vi, expect } from "vitest";
|
||||
|
||||
import { appStoreMetadata } from "@calcom/app-store/apps.metadata.generated";
|
||||
import { SchedulingType } from "@calcom/prisma/enums";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
|
||||
describe("Seated Round Robin Events", () => {
|
||||
setupAndTeardown();
|
||||
|
||||
test("For second seat booking, organizer remains the same with no team members included", async () => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
const EventManager = (await import("@calcom/lib/EventManager")).default;
|
||||
|
||||
const eventManagerSpy = vi.spyOn(EventManager.prototype, "updateCalendarAttendees");
|
||||
|
||||
const booker = getBooker({
|
||||
email: "seat2@example.com",
|
||||
name: "Seat 2",
|
||||
});
|
||||
|
||||
const assignedHost = getOrganizer({
|
||||
name: "Assigned Host",
|
||||
email: "assigned-host@example.com",
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
});
|
||||
|
||||
const teamMembers = [
|
||||
{
|
||||
name: "Team Member 1",
|
||||
username: "team-member-1",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-1@example.com",
|
||||
id: 102,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
{
|
||||
name: "Team Member 2",
|
||||
username: "team-member-2",
|
||||
timeZone: Timezones["+5:30"],
|
||||
defaultScheduleId: null,
|
||||
email: "team-member-2@example.com",
|
||||
id: 103,
|
||||
schedules: [TestData.schedules.IstEveningShift],
|
||||
},
|
||||
];
|
||||
|
||||
const bookingId = 1;
|
||||
const bookingUid = "abc123";
|
||||
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
||||
const bookingStartTime = `${plus1DateString}T04:00:00Z`;
|
||||
const bookingEndTime = `${plus1DateString}T04:30:00Z`;
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 1,
|
||||
slug: "seated-round-robin-event",
|
||||
slotInterval: 30,
|
||||
length: 30,
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
users: [{ id: assignedHost.id }, { id: teamMembers[0].id }, { id: teamMembers[1].id }],
|
||||
hosts: [
|
||||
{ userId: assignedHost.id, isFixed: false },
|
||||
{ userId: teamMembers[0].id, isFixed: false },
|
||||
{ userId: teamMembers[1].id, isFixed: false },
|
||||
],
|
||||
seatsPerTimeSlot: 3,
|
||||
seatsShowAttendees: false,
|
||||
},
|
||||
],
|
||||
bookings: [
|
||||
{
|
||||
id: bookingId,
|
||||
uid: bookingUid,
|
||||
eventTypeId: 1,
|
||||
status: BookingStatus.ACCEPTED,
|
||||
startTime: bookingStartTime,
|
||||
endTime: bookingEndTime,
|
||||
userId: assignedHost.id, // This is the assigned host for the booking
|
||||
metadata: {
|
||||
videoCallUrl: "https://existing-daily-video-call-url.example.com",
|
||||
},
|
||||
references: [
|
||||
{
|
||||
type: appStoreMetadata.dailyvideo.type,
|
||||
uid: "MOCK_ID",
|
||||
meetingId: "MOCK_ID",
|
||||
meetingPassword: "MOCK_PASS",
|
||||
meetingUrl: "http://mock-dailyvideo.example.com",
|
||||
credentialId: null,
|
||||
},
|
||||
],
|
||||
attendees: [
|
||||
getMockBookingAttendee({
|
||||
id: 1,
|
||||
name: "Seat 1",
|
||||
email: "seat1@test.com",
|
||||
locale: "en",
|
||||
timeZone: "America/Toronto",
|
||||
bookingSeat: {
|
||||
referenceUid: "booking-seat-1",
|
||||
data: {},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
organizer: assignedHost,
|
||||
usersApartFromOrganizer: [...teamMembers],
|
||||
})
|
||||
);
|
||||
|
||||
mockSuccessfulVideoMeetingCreation({
|
||||
metadataLookupKey: "dailyvideo",
|
||||
videoMeetingData: {
|
||||
id: "MOCK_ID",
|
||||
password: "MOCK_PASS",
|
||||
url: `http://mock-dailyvideo.example.com/meeting-1`,
|
||||
},
|
||||
});
|
||||
|
||||
const reqBookingUser = "seatedAttendee";
|
||||
|
||||
const mockBookingData = getMockRequestDataForBooking({
|
||||
data: {
|
||||
eventTypeId: 1,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
bookingUid: bookingUid,
|
||||
user: reqBookingUser,
|
||||
},
|
||||
});
|
||||
|
||||
await handleNewBooking({
|
||||
bookingData: mockBookingData,
|
||||
});
|
||||
|
||||
expect(eventManagerSpy).toHaveBeenCalled();
|
||||
|
||||
const calendarEvent = eventManagerSpy.mock.calls[0][0];
|
||||
|
||||
expect(calendarEvent.organizer.email).toBe(assignedHost.email);
|
||||
|
||||
expect(calendarEvent.team?.members).toBeDefined();
|
||||
expect(calendarEvent.team?.members.length).toBe(0);
|
||||
|
||||
const teamMemberEmails = calendarEvent.team?.members.map((member) => member.email);
|
||||
expect(teamMemberEmails).not.toContain(teamMembers[0].email);
|
||||
expect(teamMemberEmails).not.toContain(teamMembers[1].email);
|
||||
});
|
||||
});
|
||||
@@ -41,6 +41,7 @@ export type IsFixedAwareUser = User & {
|
||||
weight?: number;
|
||||
userLevelSelectedCalendars: SelectedCalendar[];
|
||||
allSelectedCalendars: SelectedCalendar[];
|
||||
groupId?: string | null;
|
||||
availabilityData?: GetUserAvailabilityResult;
|
||||
};
|
||||
|
||||
|
||||
@@ -194,8 +194,10 @@ const Days = ({
|
||||
const getPadding = (day: number) => (browsingDate.set("date", day).day() - weekStart + 7) % 7;
|
||||
const totalDays = daysInMonth(browsingDate);
|
||||
|
||||
const showNextMonthDays = isSecondWeekOver && !isCompact;
|
||||
|
||||
// Only apply end-of-month logic for main monthly view (not compact sidebar)
|
||||
if (isSecondWeekOver && !isCompact) {
|
||||
if (showNextMonthDays) {
|
||||
const startDay = 8;
|
||||
const pad = getPadding(startDay);
|
||||
days = Array(pad).fill(null);
|
||||
@@ -337,7 +339,7 @@ const Days = ({
|
||||
active={isActive(day)}
|
||||
away={away}
|
||||
emoji={emoji}
|
||||
showMonthTooltip={isSecondWeekOver && !isCompact}
|
||||
showMonthTooltip={showNextMonthDays && !disabled && day.month() !== browsingDate.month()}
|
||||
isFirstDayOfNextMonth={isFirstDayOfNextMonth}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -25,6 +25,17 @@ vi.mock("@calcom/prisma", () => {
|
||||
|
||||
vi.mock("stripe");
|
||||
|
||||
vi.mock("@calcom/lib/server/i18n", () => {
|
||||
return {
|
||||
getTranslation: async (locale: string, namespace: string) => {
|
||||
const t = (key: string) => key;
|
||||
t.locale = locale;
|
||||
t.namespace = namespace;
|
||||
return t;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("@calcom/lib/constants", async () => {
|
||||
const actual = (await vi.importActual("@calcom/lib/constants")) as typeof import("@calcom/lib/constants");
|
||||
return {
|
||||
|
||||
@@ -185,7 +185,7 @@ const handleGroupEvents = async (event: DirectorySyncEvent, organizationId: numb
|
||||
});
|
||||
|
||||
// Send emails to new members
|
||||
const newMembers = users.filter((user) => !user.teams.find((team) => team.id === group.teamId));
|
||||
const newMembers = users.filter((user) => !user.teams.find((team) => team.teamId === group.teamId));
|
||||
const newOrgMembers = users.filter(
|
||||
(user) => !user.profiles.find((profile) => profile.organizationId === organizationId)
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user