refactor: platform docs and oauth webhook auth (#21488)
* fix: Cannot read properties of undefined (reading 'id') * docs: managed users dont have cal.com page * docs: reassign works only for round robin bookings * refactor: put OAuthClientWebhooksController behind ApiAuthGuard * fix: tests * fix: typo
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+2
-2
@@ -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],
|
||||
|
||||
+2
-2
@@ -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,
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user