-
Notifications
You must be signed in to change notification settings - Fork 0
Code Review Bench PR #25771 - feat: update recording, transcript endpoint and add tests #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -212,10 +212,9 @@ export class BookingsController_2024_08_13 { | |||||
| } | ||||||
|
|
||||||
| @Get("/:bookingUid/recordings") | ||||||
| // @Pbac(["booking.readRecordings"]) | ||||||
| @Permissions([BOOKING_READ]) | ||||||
| @UseGuards(BookingUidGuard) | ||||||
| // @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard) | ||||||
| @Pbac(["booking.readRecordings"]) | ||||||
| @Permissions([BOOKING_WRITE]) | ||||||
| @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard) | ||||||
| @ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER) | ||||||
| @ApiOperation({ | ||||||
| summary: "Get all the recordings for the booking", | ||||||
|
|
@@ -225,21 +224,18 @@ export class BookingsController_2024_08_13 { | |||||
| `, | ||||||
| }) | ||||||
| async getBookingRecordings(@Param("bookingUid") bookingUid: string): Promise<GetBookingRecordingsOutput> { | ||||||
| const recordings = await this.calVideoService.getRecordings(bookingUid); | ||||||
| const recordings = this.calVideoService.getRecordings(bookingUid); | ||||||
|
|
||||||
| return { | ||||||
| status: SUCCESS_STATUS, | ||||||
| data: recordings, | ||||||
| message: | ||||||
| "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.", | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| @Get("/:bookingUid/transcripts") | ||||||
| // @Pbac(["booking.readRecordings"]) | ||||||
| @Pbac(["booking.readRecordings"]) | ||||||
| @Permissions([BOOKING_READ]) | ||||||
| @UseGuards(BookingUidGuard) | ||||||
| // @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard) | ||||||
| @UseGuards(BookingPbacGuard, ApiAuthGuard, BookingUidGuard) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| @UseGuards(BookingPbacGuard, ApiAuthGuard, BookingUidGuard) | |
| @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard) |
- Apply suggested fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 Bug: Missing
awaiton asyncgetRecordings()returns a PromiseCalVideoService.getRecordings()is anasyncmethod that returnsPromise<RecordingItem[]>(it internallyawaits database queries andPromise.all). Theawaitwas removed from the call in the controller, sorecordingsis now aPromiseobject, not the resolved array.The return type annotation says
Promise<GetBookingRecordingsOutput>withdata: RecordingItem[], but the actualdatafield will contain an unresolved Promise. This will result in the API returning"data": {}(a serialized Promise object) instead of the actual recordings array, effectively breaking the recordings endpoint for all callers.The test mocks this with
mockResolvedValue([])which returns a Promise — and since the handler isasync, the returned object'sdatafield will be a Promise that NestJS may or may not auto-resolve depending on serialization timing, but TypeScript's type system is being circumvented here.Was this helpful? React with 👍 / 👎