Skip to content

Commit fc1d6ae

Browse files
authored
refactor: platform docs and oauth webhook auth (calcom#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
1 parent 26b4b7a commit fc1d6ae

7 files changed

Lines changed: 83 additions & 10 deletions

File tree

apps/api/v2/src/ee/bookings/2024-08-13/controllers/bookings.controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ export class BookingsController_2024_08_13 {
290290
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
291291
@ApiOperation({
292292
summary: "Reassign a booking to auto-selected host",
293-
description: "The provided authorization header refers to the owner of the booking.",
293+
description:
294+
"Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
294295
})
295296
async reassignBooking(
296297
@Param("bookingUid") bookingUid: string,
@@ -311,7 +312,8 @@ export class BookingsController_2024_08_13 {
311312
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
312313
@ApiOperation({
313314
summary: "Reassign a booking to a specific host",
314-
description: "The provided authorization header refers to the owner of the booking.",
315+
description:
316+
"Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
315317
})
316318
async reassignBookingToUser(
317319
@Param("bookingUid") bookingUid: string,

apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ export class BookingsService_2024_08_13 {
108108
this.errorsBookingsService.handleEventTypeToBeBookedNotFound(body);
109109
}
110110

111+
if (eventType.schedulingType === "MANAGED") {
112+
throw new BadRequestException(
113+
`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.`
114+
);
115+
}
116+
111117
body.eventTypeId = eventType.id;
112118

113119
if ("instant" in body && body.instant) {

apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repo
2121
import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture";
2222
import { WebhookRepositoryFixture } from "test/fixtures/repository/webhooks.repository.fixture";
2323
import { randomString } from "test/utils/randomString";
24-
import { withNextAuth } from "test/utils/withNextAuth";
24+
import { withApiAuth } from "test/utils/withApiAuth";
2525

2626
import { PlatformOAuthClient, Team, Webhook } from "@calcom/prisma/client";
2727

@@ -47,7 +47,7 @@ describe("OAuth client WebhooksController (e2e)", () => {
4747
let webhook: OAuthClientWebhookOutputResponseDto["data"];
4848

4949
beforeAll(async () => {
50-
const moduleRef = await withNextAuth(
50+
const moduleRef = await withApiAuth(
5151
userEmail,
5252
Test.createTestingModule({
5353
imports: [AppModule, PrismaModule, UsersModule, TokensModule],

apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { API_VERSIONS_VALUES } from "@/lib/api-versions";
22
import { MembershipRoles } from "@/modules/auth/decorators/roles/membership-roles.decorator";
3-
import { NextAuthGuard } from "@/modules/auth/guards/next-auth/next-auth.guard";
3+
import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard";
44
import { OrganizationRolesGuard } from "@/modules/auth/guards/organization-roles/organization-roles.guard";
55
import { GetWebhook } from "@/modules/webhooks/decorators/get-webhook-decorator";
66
import { IsOAuthClientWebhookGuard } from "@/modules/webhooks/guards/is-oauth-client-webhook-guard";
@@ -29,7 +29,7 @@ import { OAuthClientGuard } from "../../guards/oauth-client-guard";
2929
path: "/v2/oauth-clients/:clientId/webhooks",
3030
version: API_VERSIONS_VALUES,
3131
})
32-
@UseGuards(NextAuthGuard, OrganizationRolesGuard, OAuthClientGuard)
32+
@UseGuards(ApiAuthGuard, OrganizationRolesGuard, OAuthClientGuard)
3333
@DocsTags("Platform / Webhooks")
3434
@ApiHeader({
3535
name: X_CAL_SECRET_KEY,

apps/api/v2/swagger/documentation.json

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,16 @@
15261526
"type": "string"
15271527
}
15281528
},
1529+
{
1530+
"name": "bookingUid",
1531+
"required": false,
1532+
"in": "query",
1533+
"description": "Filter bookings by the booking Uid.",
1534+
"example": "2NtaeaVcKfpmSZ4CthFdfk",
1535+
"schema": {
1536+
"type": "string"
1537+
}
1538+
},
15291539
{
15301540
"name": "eventTypeIds",
15311541
"required": false,
@@ -5442,6 +5452,16 @@
54425452
"type": "string"
54435453
}
54445454
},
5455+
{
5456+
"name": "bookingUid",
5457+
"required": false,
5458+
"in": "query",
5459+
"description": "Filter bookings by the booking Uid.",
5460+
"example": "2NtaeaVcKfpmSZ4CthFdfk",
5461+
"schema": {
5462+
"type": "string"
5463+
}
5464+
},
54455465
{
54465466
"name": "eventTypeIds",
54475467
"required": false,
@@ -6819,6 +6839,16 @@
68196839
"type": "string"
68206840
}
68216841
},
6842+
{
6843+
"name": "bookingUid",
6844+
"required": false,
6845+
"in": "query",
6846+
"description": "Filter bookings by the booking Uid.",
6847+
"example": "2NtaeaVcKfpmSZ4CthFdfk",
6848+
"schema": {
6849+
"type": "string"
6850+
}
6851+
},
68226852
{
68236853
"name": "eventTypeIds",
68246854
"required": false,
@@ -7251,7 +7281,7 @@
72517281
"post": {
72527282
"operationId": "BookingsController_2024_08_13_reassignBooking",
72537283
"summary": "Reassign a booking to auto-selected host",
7254-
"description": "The provided authorization header refers to the owner of the booking.",
7284+
"description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
72557285
"parameters": [
72567286
{
72577287
"name": "cal-api-version",
@@ -7302,7 +7332,7 @@
73027332
"post": {
73037333
"operationId": "BookingsController_2024_08_13_reassignBookingToUser",
73047334
"summary": "Reassign a booking to a specific host",
7305-
"description": "The provided authorization header refers to the owner of the booking.",
7335+
"description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
73067336
"parameters": [
73077337
{
73087338
"name": "cal-api-version",
@@ -15029,6 +15059,7 @@
1502915059
},
1503015060
"address": {
1503115061
"type": "string",
15062+
"minLength": 1,
1503215063
"example": "123 Example St, City, Country"
1503315064
},
1503415065
"public": {

docs/api-reference/v2/openapi.json

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,16 @@
14661466
"type": "string"
14671467
}
14681468
},
1469+
{
1470+
"name": "bookingUid",
1471+
"required": false,
1472+
"in": "query",
1473+
"description": "Filter bookings by the booking Uid.",
1474+
"example": "2NtaeaVcKfpmSZ4CthFdfk",
1475+
"schema": {
1476+
"type": "string"
1477+
}
1478+
},
14691479
{
14701480
"name": "eventTypeIds",
14711481
"required": false,
@@ -5208,6 +5218,16 @@
52085218
"type": "string"
52095219
}
52105220
},
5221+
{
5222+
"name": "bookingUid",
5223+
"required": false,
5224+
"in": "query",
5225+
"description": "Filter bookings by the booking Uid.",
5226+
"example": "2NtaeaVcKfpmSZ4CthFdfk",
5227+
"schema": {
5228+
"type": "string"
5229+
}
5230+
},
52115231
{
52125232
"name": "eventTypeIds",
52135233
"required": false,
@@ -6519,6 +6539,16 @@
65196539
"type": "string"
65206540
}
65216541
},
6542+
{
6543+
"name": "bookingUid",
6544+
"required": false,
6545+
"in": "query",
6546+
"description": "Filter bookings by the booking Uid.",
6547+
"example": "2NtaeaVcKfpmSZ4CthFdfk",
6548+
"schema": {
6549+
"type": "string"
6550+
}
6551+
},
65226552
{
65236553
"name": "eventTypeIds",
65246554
"required": false,
@@ -6929,7 +6959,7 @@
69296959
"post": {
69306960
"operationId": "BookingsController_2024_08_13_reassignBooking",
69316961
"summary": "Reassign a booking to auto-selected host",
6932-
"description": "The provided authorization header refers to the owner of the booking.",
6962+
"description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
69336963
"parameters": [
69346964
{
69356965
"name": "cal-api-version",
@@ -6978,7 +7008,7 @@
69787008
"post": {
69797009
"operationId": "BookingsController_2024_08_13_reassignBookingToUser",
69807010
"summary": "Reassign a booking to a specific host",
6981-
"description": "The provided authorization header refers to the owner of the booking.",
7011+
"description": "Currently only supports reassigning host for round robin bookings. The provided authorization header refers to the owner of the booking.",
69827012
"parameters": [
69837013
{
69847014
"name": "cal-api-version",
@@ -14135,6 +14165,7 @@
1413514165
},
1413614166
"address": {
1413714167
"type": "string",
14168+
"minLength": 1,
1413814169
"example": "123 Example St, City, Country"
1413914170
},
1414014171
"public": {

docs/platform/quickstart.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ After creating a “managed user” you will receive the user ID, an access and
3434
#### What is it not?
3535
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.
3636

37+
❗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,
38+
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.
39+
3740
### Create managed users via our API
3841

3942
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).

0 commit comments

Comments
 (0)