feat: expose host meeting token in Platform API v2 for Cal Video (Dai…#28809
feat: expose host meeting token in Platform API v2 for Cal Video (Dai…#28809nordam312 wants to merge 3 commits intocalcom:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRepository queries were updated to include the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts (1)
86-86: Consider makingreferencesoptional in the type for defensive coding.The
referencesfield is typed as required, but the code defensively uses optional chaining (databaseBooking.references?.find). While all repository methods feeding into this service have been updated to includereferences, typing it as optional (references?: ...) would make the type more accurately reflect the runtime safety pattern and prevent future regressions if a new repository method is added withoutreferences.♻️ Suggested change
- references: { type: string; meetingPassword: string | null }[]; + references?: { type: string; meetingPassword: string | null }[];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts` at line 86, The references property on the Booking output type is declared as required but the code (in output.service.ts) defensively accesses databaseBooking.references using optional chaining; change the declaration of references to be optional (e.g., references?: { type: string; meetingPassword: string | null }[] ) so the type matches runtime usage and prevents future regressions—update the type definition that contains references (the booking/output type used in the OutputService logic) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts`:
- Around line 752-755: The call to
eventTypeAccessService.userIsEventTypeAdminOrOwner currently casts user to
NonNullable<AuthOptionalUser> which is unsafe because the passed user lacks
isSystemAdmin; instead, construct a properly typed auth user or change the call
to accept the narrower type. Fix by creating a new object (e.g., const authUser
= { ...user, isSystemAdmin: false } or derive isSystemAdmin appropriately) and
pass authUser into userIsEventTypeAdminOrOwner(formatted.eventType), or update
userIsEventTypeAdminOrOwner to accept the incoming `{ email: string; id: number;
orgId?: number }` shape and adjust internals accordingly so no unsafe cast is
used.
---
Nitpick comments:
In `@apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts`:
- Line 86: The references property on the Booking output type is declared as
required but the code (in output.service.ts) defensively accesses
databaseBooking.references using optional chaining; change the declaration of
references to be optional (e.g., references?: { type: string; meetingPassword:
string | null }[] ) so the type matches runtime usage and prevents future
regressions—update the type definition that contains references (the
booking/output type used in the OutputService logic) accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3bdf7d12-f8be-4edf-924d-1bd6e4fbcfa5
📒 Files selected for processing (6)
apps/api/v2/src/ee/bookings/2024-08-13/repositories/bookings.repository.tsapps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.tsapps/api/v2/src/ee/bookings/2024-08-13/services/output.service.tsapps/api/v2/src/modules/booking-seat/booking-seat.repository.tsapps/web/modules/videos/views/videos-single-view.tsxpackages/platform/types/bookings/2024-08-13/outputs/booking.output.ts
baf7417 to
248572c
Compare
|
Can someone check my PR please and add the 'run-ci' label so I can check if my changes pass the tests? Thanks! And sorry for the force-push, I was trying to resolve some issues and sync with the main branch. I've now updated the code and it's ready for the run-ci checks |
…ly.co)
What does this PR do?
Motivation & Context:
When using the Platform API v2 with managed users and Cal Video (Daily.co integration), there was no way to retrieve the host meeting token (
meetingPassword) for a booking. This prevented platform consumers from giving their hosts admin/moderator controls in the video call (e.g., mute all, kick, recording).Solution:
This PR securely exposes the Daily.co
hostTokenin Platform API v2 booking responses strictly for authorized users (EventType Owners & Admins). It also updates the frontendvideos-single-viewto accepttokenas a URL query parameter, enabling URL-based admin access for managed users routing from the Platform API.Changes:
API Types & Schema: Added
hostTokenproperty to the [BaseBookingOutput_2024_08_13] schema.Services
([output.service.ts] & [bookings.service.ts]
isHostOrAdminutilizingeventTypeAccessService.userIsEventTypeAdminOrOwner.meetingPasswordexclusively when the recipient has host permissions.Repository layer:
Ensured
referencesare fetched alongsideattendeesanduserto populate thehostToken.Web App:
Extracted the URL
?token=...parameter natively usinguseSearchParamswithin [JoinCall] in videos-single-view.tsx component logic to initialize theDailyIframewith Host privileges.Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Use an
eventTypeIdthat leverages Cal Video (Daily.co) via API v2.Issue a
GET /v2/bookings/:uidusing an API Key authorized out to the Event Organizer.hostToken: "eyJhbG..."Issue the same GET request but without host privileges.
hostTokenshould be entirely undefined/missing from the payload.Visit
http://localhost:3000/video/<uid>?token=<hostToken>in an incognito window. You should observe that host-exclusive controls (like Mute All) are enabled.Checklist