Skip to content

Scheduling infrastructure for absolutely everyone.

refactor: platform docs and oauth webhook auth (#21488)

Lauris Skraucisfc1d6ae40258
diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts
index 6dc57d9dca6..f891b7d866b 100644
--- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts
+++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts
@@ -290,7 +290,8 @@ export class BookingsController_2024_08_13 {
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@ApiOperation({
summary: "Reassign a booking to auto-selected host",
- description: "The provided authorization header refers to the owner of the booking.",
+ description:
+ "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
})
async reassignBooking(
@Param("bookingUid") bookingUid: string,
@@ -311,7 +312,8 @@ export class BookingsController_2024_08_13 {
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
@ApiOperation({
summary: "Reassign a booking to a specific host",
- description: "The provided authorization header refers to the owner of the booking.",
+ description:
+ "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
})
async reassignBookingToUser(
@Param("bookingUid") bookingUid: string,
diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
index 7f0c1fd64bb..c1b16737a5d 100644
--- a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
+++ b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
@@ -108,6 +108,12 @@ export class BookingsService_2024_08_13 {
this.errorsBookingsService.handleEventTypeToBeBookedNotFound(body);
}
+ if (eventType.schedulingType === "MANAGED") {
+ throw new BadRequestException(
+ `Event type with id=${eventType.id} is the parent managed event type that can't be booked. You have to provide the child event type id aka id of event type that has been assigned to one of the users.`
+ );
+ }
+
body.eventTypeId = eventType.id;
if ("instant" in body && body.instant) {
diff --git a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts
index 7979017decf..e38460aecdb 100644
--- a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts
+++ b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts
@@ -21,7 +21,7 @@ import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repo
import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture";
import { WebhookRepositoryFixture } from "test/fixtures/repository/webhooks.repository.fixture";
import { randomString } from "test/utils/randomString";
-import { withNextAuth } from "test/utils/withNextAuth";
+import { withApiAuth } from "test/utils/withApiAuth";
import { PlatformOAuthClient, Team, Webhook } from "@calcom/prisma/client";
@@ -47,7 +47,7 @@ describe("OAuth client WebhooksController (e2e)", () => {
let webhook: OAuthClientWebhookOutputResponseDto["data"];
beforeAll(async () => {
- const moduleRef = await withNextAuth(
+ const moduleRef = await withApiAuth(
userEmail,
Test.createTestingModule({
imports: [AppModule, PrismaModule, UsersModule, TokensModule],
diff --git a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.ts b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.ts
index 8dd6882b774..c141f0df36c 100644
--- a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.ts
+++ b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.ts
@@ -1,6 +1,6 @@
import { API_VERSIONS_VALUES } from "@/lib/api-versions";
import { MembershipRoles } from "@/modules/auth/decorators/roles/membership-roles.decorator";
-import { NextAuthGuard } from "@/modules/auth/guards/next-auth/next-auth.guard";
+import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard";
import { OrganizationRolesGuard } from "@/modules/auth/guards/organization-roles/organization-roles.guard";
import { GetWebhook } from "@/modules/webhooks/decorators/get-webhook-decorator";
import { IsOAuthClientWebhookGuard } from "@/modules/webhooks/guards/is-oauth-client-webhook-guard";
@@ -29,7 +29,7 @@ import { OAuthClientGuard } from "../../guards/oauth-client-guard";
path: "/v2/oauth-clients/:clientId/webhooks",
version: API_VERSIONS_VALUES,
})
-@UseGuards(NextAuthGuard, OrganizationRolesGuard, OAuthClientGuard)
+@UseGuards(ApiAuthGuard, OrganizationRolesGuard, OAuthClientGuard)
@DocsTags("Platform / Webhooks")
@ApiHeader({
name: X_CAL_SECRET_KEY,
diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.json
index 5a7f242baec..6c614762a72 100644
--- a/apps/api/v2/swagger/documentation.json
+++ b/apps/api/v2/swagger/documentation.json
@@ -1526,6 +1526,16 @@
"type": "string"
}
},
+ {
+ "name": "bookingUid",
+ "required": false,
+ "in": "query",
+ "description": "Filter bookings by the booking Uid.",
+ "example": "2NtaeaVcKfpmSZ4CthFdfk",
+ "schema": {
+ "type": "string"
+ }
+ },
{
"name": "eventTypeIds",
"required": false,
@@ -5442,6 +5452,16 @@
"type": "string"
}
},
+ {
+ "name": "bookingUid",
+ "required": false,
+ "in": "query",
+ "description": "Filter bookings by the booking Uid.",
+ "example": "2NtaeaVcKfpmSZ4CthFdfk",
+ "schema": {
+ "type": "string"
+ }
+ },
{
"name": "eventTypeIds",
"required": false,
@@ -6819,6 +6839,16 @@
"type": "string"
}
},
+ {
+ "name": "bookingUid",
+ "required": false,
+ "in": "query",
+ "description": "Filter bookings by the booking Uid.",
+ "example": "2NtaeaVcKfpmSZ4CthFdfk",
+ "schema": {
+ "type": "string"
+ }
+ },
{
"name": "eventTypeIds",
"required": false,
@@ -7251,7 +7281,7 @@
"post": {
"operationId": "BookingsController_2024_08_13_reassignBooking",
"summary": "Reassign a booking to auto-selected host",
- "description": "The provided authorization header refers to the owner of the booking.",
+ "description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
"parameters": [
{
"name": "cal-api-version",
@@ -7302,7 +7332,7 @@
"post": {
"operationId": "BookingsController_2024_08_13_reassignBookingToUser",
"summary": "Reassign a booking to a specific host",
- "description": "The provided authorization header refers to the owner of the booking.",
+ "description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
"parameters": [
{
"name": "cal-api-version",
@@ -15029,6 +15059,7 @@
},
"address": {
"type": "string",
+ "minLength": 1,
"example": "123 Example St, City, Country"
},
"public": {
diff --git a/docs/api-reference/v2/openapi.json b/docs/api-reference/v2/openapi.json
index 7db3cece4c9..b18c8df9525 100644
--- a/docs/api-reference/v2/openapi.json
+++ b/docs/api-reference/v2/openapi.json
@@ -1466,6 +1466,16 @@
"type": "string"
}
},
+ {
+ "name": "bookingUid",
+ "required": false,
+ "in": "query",
+ "description": "Filter bookings by the booking Uid.",
+ "example": "2NtaeaVcKfpmSZ4CthFdfk",
+ "schema": {
+ "type": "string"
+ }
+ },
{
"name": "eventTypeIds",
"required": false,
@@ -5208,6 +5218,16 @@
"type": "string"
}
},
+ {
+ "name": "bookingUid",
+ "required": false,
+ "in": "query",
+ "description": "Filter bookings by the booking Uid.",
+ "example": "2NtaeaVcKfpmSZ4CthFdfk",
+ "schema": {
+ "type": "string"
+ }
+ },
{
"name": "eventTypeIds",
"required": false,
@@ -6519,6 +6539,16 @@
"type": "string"
}
},
+ {
+ "name": "bookingUid",
+ "required": false,
+ "in": "query",
+ "description": "Filter bookings by the booking Uid.",
+ "example": "2NtaeaVcKfpmSZ4CthFdfk",
+ "schema": {
+ "type": "string"
+ }
+ },
{
"name": "eventTypeIds",
"required": false,
@@ -6929,7 +6959,7 @@
"post": {
"operationId": "BookingsController_2024_08_13_reassignBooking",
"summary": "Reassign a booking to auto-selected host",
- "description": "The provided authorization header refers to the owner of the booking.",
+ "description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
"parameters": [
{
"name": "cal-api-version",
@@ -6978,7 +7008,7 @@
"post": {
"operationId": "BookingsController_2024_08_13_reassignBookingToUser",
"summary": "Reassign a booking to a specific host",
- "description": "The provided authorization header refers to the owner of the booking.",
+ "description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
"parameters": [
{
"name": "cal-api-version",
@@ -14135,6 +14165,7 @@
},
"address": {
"type": "string",
+ "minLength": 1,
"example": "123 Example St, City, Country"
},
"public": {
diff --git a/docs/platform/quickstart.mdx b/docs/platform/quickstart.mdx
index d9ad454f929..a7e95084778 100644
--- a/docs/platform/quickstart.mdx
+++ b/docs/platform/quickstart.mdx
@@ -34,6 +34,9 @@ After creating a “managed user” you will receive the user ID, an access and
#### What is it not?
It's important to clarify that a "managed user" is completely independent of a regular user account on cal.com, meaning you don't need your users to register on cal.com web application.
+❗Managed users do not get a public cal.com page like normal cal.com users do aka if you create a managed user the managed user won't have cal.com/managed-user page, because the point of platform solution is to integrate scheduling into your platform,
+so instead the managed user public page will be at your-platform.com/managed-user and there you fetch event types of the managed user using our api or react hooks and display them.
+
### Create managed users via our API
We now need the OAuth client’s “client ID” and “client secret” that you can find in [https://app.cal.com/settings/organizations/platform/oauth-clients](https://app.cal.com/settings/organizations/platform/oauth-clients).