-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat: v2 slots new version #18758
base: main
Are you sure you want to change the base?
feat: v2 slots new version #18758
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
Hello, I’d like to emphasize an important point. Alongside the default "reserve slot" behavior, which reserves a slot for 5 minutes, we need the flexibility to define how far into the future a slot can be reserved. For instance, instead of the default 5-minute duration, we should be able to reserve a slot for an extended period—up to 1000 years, if needed—effectively keeping the slot reserved indefinitely until we trigger a "Delete a selected slot" API or complete a booking. This functionality would be particularly useful when building on top of Cal.com using its platform API, such as when creating predefined classes. |
If possible, it would be great to include the ability to return reserved slots along with their slot ID and datetime. This would be especially beneficial for managing predefined timed classes or events across various platforms. |
Thanks for the input and it's a great idea! Luckily, this is implemented in this PR. Here is an example POST request made to
|
The response of reserving a slot can be viewed here: reserve-slot.output.ts Slots don't have IDs per se, but reservations do, so response contains UID of the reservation and the |
|
||
1. By event type id. Event type id can be of user and team event types. Example '/v2/slots?eventTypeId=10&start=2050-09-05&end=2050-09-06&timeZone=Europe/Rome' | ||
|
||
2. By event type slug + username. Example '/v2/slots?eventTypeSlug=intro&username=bob&start=2050-09-05&end=2050-09-06' |
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.
we should enable providing orgSlug or orgId, there can be conflicts between username + eventslug of org users being the same than username + eventslug of non org ursers
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.
I see in the inputs that we allow orgSlug, we can just specify here that for org users they should also pass the org slug
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.
Good catch - in commit fix: handle same username in org and non org I make sure that we can scope by organizationSlug
query parameter and added tests in slots.controller.e2e-spec.ts - i set up org user with profile username X and event type Y and then normal user with username X and event type Y and then fetch org user availability using profile username + event type slug using organizationSlug
param and then normal user without organizationParam
. The tests are on line 1859.
@IsInt() | ||
@IsOptional() | ||
@ApiPropertyOptional({ | ||
example: 5, | ||
description: | ||
"For how many minutes the slot should be reserved - for this long time noone else can book this event type at `start` time.", | ||
}) | ||
reservationDuration = 5; |
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.
this is a cool feature but we should only enable it when authenticated with apikey / next auth / access token
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.
too easy to abuse it to block the schedule of someone
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.
if not authenticated force 5
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.
Great! But instead of forcing back to 5, return an auth validation error, as sensitive and high-dependency cases can be critical for the (Platform).
If no duration is set, it should function normally without any type of auth, with 5 min as default duration.
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.
Great idea! In commit fix: allow reservationDuration only for authed requests I implemented that
- if no authentification is passed then
reservationDuration
can't be set - if invalid authentification is passed then 400 bad request error is thrown.
This can be seen in e2e tests slots.controller.e2e-spec.ts
@@ -37,22 +37,6 @@ export class OrganizationsUsersRepository { | |||
}); | |||
} | |||
|
|||
async getOrganizationUserByUsername(orgId: number, username: string) { |
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.
@joeauyeung had added this code but I replaced it with 'getOrganizationUserByUsername' below which does not check 'User.username' like this function did but 'Profile.username'.
Linear CAL-5052