Skip to content

Commit 5818da4

Browse files
Udit-takkarvolnei
andauthored
feat: update recording, transcript endpoint and add tests (#25771)
* feat: add tests and update endpoint * chore: undo --------- Co-authored-by: Volnei Munhoz <volnei@cal.com>
1 parent d381c2c commit 5818da4

4 files changed

Lines changed: 61 additions & 82 deletions

File tree

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,9 @@ export class BookingsController_2024_08_13 {
212212
}
213213

214214
@Get("/:bookingUid/recordings")
215-
// @Pbac(["booking.readRecordings"])
215+
@Pbac(["booking.readRecordings"])
216216
@Permissions([BOOKING_READ])
217-
@UseGuards(BookingUidGuard)
218-
// @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard)
217+
@UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard)
219218
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
220219
@ApiOperation({
221220
summary: "Get all the recordings for the booking",
@@ -230,16 +229,13 @@ export class BookingsController_2024_08_13 {
230229
return {
231230
status: SUCCESS_STATUS,
232231
data: recordings,
233-
message:
234-
"This endpoint will require authentication in a future release. Please update your integration to include valid credentials. See https://cal.com/docs/api-reference/v2/introduction#authentication for details.",
235232
};
236233
}
237234

238235
@Get("/:bookingUid/transcripts")
239-
// @Pbac(["booking.readRecordings"])
236+
@Pbac(["booking.readRecordings"])
240237
@Permissions([BOOKING_READ])
241-
@UseGuards(BookingUidGuard)
242-
// @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard)
238+
@UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard)
243239
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
244240
@ApiOperation({
245241
summary: "Get Cal Video real time transcript download links for the booking",
@@ -258,8 +254,6 @@ export class BookingsController_2024_08_13 {
258254
return {
259255
status: SUCCESS_STATUS,
260256
data: transcripts ?? [],
261-
message:
262-
"This endpoint will require authentication in a future release. Please update your integration to include valid credentials. See https://cal.com/docs/api-reference/v2/introduction#authentication for details.",
263257
};
264258
}
265259

@@ -397,18 +391,18 @@ export class BookingsController_2024_08_13 {
397391
<Note>Please make sure to pass in the cal-api-version header value as mentioned in the Headers section. Not passing the correct value will default to an older version of this endpoint.</Note>
398392
`,
399393
})
400-
async markNoShow(
401-
@Param("bookingUid") bookingUid: string,
402-
@Body() body: MarkAbsentBookingInput_2024_08_13,
403-
@GetUser() user: ApiAuthGuardUser
404-
): Promise<MarkAbsentBookingOutput_2024_08_13> {
405-
const booking = await this.bookingsService.markAbsent(bookingUid, user.id, body, user.uuid);
406-
407-
return {
408-
status: SUCCESS_STATUS,
409-
data: booking,
410-
};
411-
}
394+
async markNoShow(
395+
@Param("bookingUid") bookingUid: string,
396+
@Body() body: MarkAbsentBookingInput_2024_08_13,
397+
@GetUser() user: ApiAuthGuardUser
398+
): Promise<MarkAbsentBookingOutput_2024_08_13> {
399+
const booking = await this.bookingsService.markAbsent(bookingUid, user.id, body, user.uuid);
400+
401+
return {
402+
status: SUCCESS_STATUS,
403+
data: booking,
404+
};
405+
}
412406

413407
@Post("/:bookingUid/reassign")
414408
@HttpCode(HttpStatus.OK)

apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/booking-access-auth.e2e-spec.ts

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -185,51 +185,51 @@ describe("Bookings Endpoints 2024-08-13", () => {
185185
});
186186
});
187187

188-
// describe("GET /v2/bookings/:bookingUid/recordings - Authorization", () => {
189-
// it("should allow booking organizer to access recordings", async () => {
190-
// const calVideoService = app.get(CalVideoService);
191-
// jest.spyOn(calVideoService, "getRecordings").mockResolvedValue([]);
192-
193-
// const response = await request(app.getHttpServer())
194-
// .get(`/v2/bookings/${testBooking.uid}/recordings`)
195-
// .set("Authorization", `Bearer ${ownerApiKey}`)
196-
// .set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
197-
// .expect(200);
198-
199-
// expect(response.body.status).toEqual(SUCCESS_STATUS);
200-
// });
201-
202-
// it("should return 403 when unauthorized user tries to access recordings", async () => {
203-
// await request(app.getHttpServer())
204-
// .get(`/v2/bookings/${testBooking.uid}/recordings`)
205-
// .set("Authorization", `Bearer ${unauthorizedApiKey}`)
206-
// .set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
207-
// .expect(403);
208-
// });
209-
// });
210-
211-
// describe("GET /v2/bookings/:bookingUid/transcripts - Authorization", () => {
212-
// it("should allow booking organizer to access transcripts", async () => {
213-
// const calVideoService = app.get(CalVideoService);
214-
// jest.spyOn(calVideoService, "getTranscripts").mockResolvedValue([]);
215-
216-
// const response = await request(app.getHttpServer())
217-
// .get(`/v2/bookings/${testBooking.uid}/transcripts`)
218-
// .set("Authorization", `Bearer ${ownerApiKey}`)
219-
// .set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
220-
// .expect(200);
221-
222-
// expect(response.body.status).toEqual(SUCCESS_STATUS);
223-
// });
224-
225-
// it("should return 403 when unauthorized user tries to access transcripts", async () => {
226-
// await request(app.getHttpServer())
227-
// .get(`/v2/bookings/${testBooking.uid}/transcripts`)
228-
// .set("Authorization", `Bearer ${unauthorizedApiKey}`)
229-
// .set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
230-
// .expect(403);
231-
// });
232-
// });
188+
describe("GET /v2/bookings/:bookingUid/recordings - Authorization", () => {
189+
it("should allow booking organizer to access recordings", async () => {
190+
const calVideoService = app.get(CalVideoService);
191+
jest.spyOn(calVideoService, "getRecordings").mockResolvedValue([]);
192+
193+
const response = await request(app.getHttpServer())
194+
.get(`/v2/bookings/${testBooking.uid}/recordings`)
195+
.set("Authorization", `Bearer ${ownerApiKey}`)
196+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
197+
.expect(200);
198+
199+
expect(response.body.status).toEqual(SUCCESS_STATUS);
200+
});
201+
202+
it("should return 403 when unauthorized user tries to access recordings", async () => {
203+
await request(app.getHttpServer())
204+
.get(`/v2/bookings/${testBooking.uid}/recordings`)
205+
.set("Authorization", `Bearer ${unauthorizedApiKey}`)
206+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
207+
.expect(403);
208+
});
209+
});
210+
211+
describe("GET /v2/bookings/:bookingUid/transcripts - Authorization", () => {
212+
it("should allow booking organizer to access transcripts", async () => {
213+
const calVideoService = app.get(CalVideoService);
214+
jest.spyOn(calVideoService, "getTranscripts").mockResolvedValue([]);
215+
216+
const response = await request(app.getHttpServer())
217+
.get(`/v2/bookings/${testBooking.uid}/transcripts`)
218+
.set("Authorization", `Bearer ${ownerApiKey}`)
219+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
220+
.expect(200);
221+
222+
expect(response.body.status).toEqual(SUCCESS_STATUS);
223+
});
224+
225+
it("should return 403 when unauthorized user tries to access transcripts", async () => {
226+
await request(app.getHttpServer())
227+
.get(`/v2/bookings/${testBooking.uid}/transcripts`)
228+
.set("Authorization", `Bearer ${unauthorizedApiKey}`)
229+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
230+
.expect(403);
231+
});
232+
});
233233

234234
afterAll(async () => {
235235
await bookingsRepositoryFixture.deleteById(testBooking.id);

packages/platform/types/bookings/2024-08-13/outputs/get-booking-recordings.output.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,4 @@ export class GetBookingRecordingsOutput {
5555
@ValidateNested({ each: true })
5656
@Type(() => RecordingItem)
5757
data!: RecordingItem[];
58-
59-
@ApiProperty({
60-
example: "This endpoint will require authentication in a future release.",
61-
required: false,
62-
})
63-
@IsString()
64-
@IsOptional()
65-
message?: string;
6658
}

packages/platform/types/bookings/2024-08-13/outputs/get-booking-transcripts.output.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,4 @@ export class GetBookingTranscriptsOutput {
1414
@IsArray()
1515
@IsString({ each: true })
1616
data!: string[];
17-
18-
@ApiProperty({
19-
example: "This endpoint will require authentication in a future release.",
20-
required: false,
21-
})
22-
@IsString()
23-
message?: string;
2417
}

0 commit comments

Comments
 (0)