feat: support slug and id on GET event-types#12491
feat: support slug and id on GET event-types#12491ouwargui wants to merge 2 commits intocalcom:mainfrom
Conversation
|
@ouwargui is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe/Alipay. |
|
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link. |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
|
Cross-referencing this PR in #12392. If the CSRF fix gets merged before this PR, it'll break anyone who was using the public TRPC endpoints as a workaround for getting an event type by slug. |
There was a problem hiding this comment.
We should rename the path to [idOrSlug]
| if (isAdmin) return; | ||
| const eventType = await prisma.eventType.findFirst({ | ||
| where: { id, users: { some: { id: userId } } }, | ||
| where: { OR: [{ id }, { slug }], AND: { users: { some: { id: userId } } } }, |
There was a problem hiding this comment.
Because it would either be id or slug when provided by user, we want to be clear if we are fetching by slug or id so using OR doesn't make sense.
Also, there could possibly be a scenario where an event-type has a numeric slug(say 123). In this case querying for event-types/123 could potentially fetch the eventType with that numeric slug. So, we need to be able to distinguish it clearly in the API request as to what the user wants.
Maybe we could go for /event-types?slug=something or a new endpoint maybe /event-types/bySlug/[slug] ?
hariombalhara
left a comment
There was a problem hiding this comment.
I think we should go for a change in logic a bit.
In agreement with @hariom. Needs different solution.
Head branch was pushed to by a user without write access
7add76d to
9c4d547
Compare
|
This PR is being marked as stale due to inactivity. |
|
not stale, i didn't have time to work on it because of the holidays, but i'm back |
|
Closing as this PR now has 0 changes |
What does this PR do?
Fixes #12411
/claim #12411
Type of change
How should this be tested?
yarn db-seed/api/event-types/:idshould support id or slug as path paramMandatory Tasks
Checklist