feat: Implement global booking limits for users#14243
feat: Implement global booking limits for users#14243asadath1395 wants to merge 78 commits intocalcom:mainfrom
Conversation
|
@asadath1395 is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link. |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (03/28/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add community label" took an action on this PR • (03/28/24)1 label was added to this PR based on Keith Williams's automation. "Add foundation team as reviewer" took an action on this PR • (04/16/24)1 reviewer was added to this PR based on Keith Williams's automation. |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 New Page AddedThe following page was added to the bundle from the code in this PR:
|
…pecified for individual events
…values are copied
… set individually
…5/cal.com into booking-global-limits
There was a problem hiding this comment.
cubic found 2 issues across 23 files. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
| allowSEOIndexing: user.allowSEOIndexing, | ||
| receiveMonthlyDigestEmail: user.receiveMonthlyDigestEmail, | ||
| ...profileData, | ||
| bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}), |
There was a problem hiding this comment.
Defaulting null bookingLimits to an empty object ({}) changes semantics—null represents "no limits", while {} passes validation as an object and may be treated as "limits present but empty", potentially altering downstream logic.
| bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}), | |
| bookingLimits: intervalLimitsType.parse(user.bookingLimits ?? null), |
| allowSEOIndexing: user.allowSEOIndexing, | ||
| receiveMonthlyDigestEmail: user.receiveMonthlyDigestEmail, | ||
| ...profileData, | ||
| bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}), |
There was a problem hiding this comment.
Using Zod's parse here means any malformed data will synchronously throw a ZodError and crash the entire request path; prefer safeParse (or a try/catch) to return a controlled error response instead of a 500.
There was a problem hiding this comment.
cubic found 1 issue across 23 files. Review it in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
| allowSEOIndexing: user.allowSEOIndexing, | ||
| receiveMonthlyDigestEmail: user.receiveMonthlyDigestEmail, | ||
| ...profileData, | ||
| bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}), |
There was a problem hiding this comment.
Using Zod's parse here means any malformed data will synchronously throw a ZodError and crash the entire request path; prefer safeParse (or a try/catch) to return a controlled error response instead of a 500.
| async () => await handleNewBooking({ bookingData: mockBookingData2 }) | ||
| ).rejects.toThrowError("booking_limit_reached"); | ||
| }); | ||
| test(`Booking limits per year`, async ({}) => { |
There was a problem hiding this comment.
@CarinaWolli We do have tests for booking limits per year
There was a problem hiding this comment.
This test is for handleNewBooking, which is working as expected and throws the error when the limit is reached. The actual bug is in availability loading, it shouldn't show open slots if the limit is already reached
|
@CarinaWolli Would you please review this PR? Maintaining this, is becoming cumbersome. Some type checks are failing, don't think they are related to my changes |
|
I am still getting the error on the yearly limit. How to reproduce:
|
|
@volnei is looking into getting the merge conflicts resolved and the PR tested to merge |
|
Superseded by #23100 |
|
@volnei Thanks for taking over! Disappointed that i couldn't take it to the finish line :(. Hope we can get your PR merged soon. |
What does this PR do?
Fixes #8985
https://www.loom.com/share/7db5ef02bc0746419c083d38998a6a48?sid=0e487055-5f25-48ae-a634-30e9da88dd7f
Type of change
Mandatory Tasks