Skip to content

feat: make redirect on booking a teams-only feature with grandfathering#28076

Closed
PeerRich wants to merge 11 commits intomainfrom
devin/1771520273-redirect-booking-teams-only
Closed

feat: make redirect on booking a teams-only feature with grandfathering#28076
PeerRich wants to merge 11 commits intomainfrom
devin/1771520273-redirect-booking-teams-only

Conversation

@PeerRich
Copy link
Member

@PeerRich PeerRich commented Feb 19, 2026

What does this PR do?

Gates the "Redirect on booking" (successRedirectUrl) feature behind a team plan, both in the UI and the API v2 backend.

UI (EventAdvancedTab)

  • Free users see a disabled toggle with an UpgradeTeamsBadge (same pattern as CalVideoSettings)
  • isRedirectUrlGrandfathered: true if eventType.successRedirectUrl is already set (from DB)
  • isRedirectUrlDisabled: true only if NOT grandfathered AND user has no team plan

API v2 Backend Enforcement

  • Create (createUserEventType): If successRedirectUrl is provided, checks the user has an accepted published team membership. Throws 403 Forbidden if not.
  • Update (updateEventType): If successRedirectUrl is being changed, first checks whether the event type already has a redirect URL (grandfathered). Only enforces the team plan check for event types with no existing redirect.
  • New MembershipsRepository.hasAcceptedPublishedTeamMembership() — checks for an accepted membership in a team with a non-null slug
  • New EventTypesRepository_2024_06_14.getSuccessRedirectUrl() — fetches only the successRedirectUrl field for grandfathering checks

Requested by: @PeerRich
Link to Devin run: https://app.devin.ai/sessions/b33de57ca82548cf9b5a8a34317b1606

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

UI

  1. Log in as a free user with an event type that has no redirect URL set → the "Redirect on booking" toggle should be disabled with an "Upgrade" badge
  2. Log in as a free user with an event type that already has a redirect URL saved → the toggle should remain enabled (grandfathered)
  3. Log in as a team plan user → the toggle should work normally regardless of existing redirect URL

API v2

  1. POST /v2/event-types as a free user with successRedirectUrl set → should return 403
  2. POST /v2/event-types as a team user with successRedirectUrl set → should succeed
  3. PATCH /v2/event-types/:id as a free user on an event type with no existing redirect, setting successRedirectUrl → should return 403
  4. PATCH /v2/event-types/:id as a free user on an event type that already has a redirect URL → should succeed (grandfathered)

Human Review Checklist

  • hasAcceptedPublishedTeamMembership vs useHasTeamPlan alignment: The API v2 check queries for an accepted membership in a team with a non-null slug. Verify this produces equivalent results to the UI's useHasTeamPlan() hook (which calls hasTeamPlanHandler via tRPC).
  • Grandfathering on update: The check uses the existing DB value. If a user clears successRedirectUrl (sets to null) and then tries to set it again later, they'd lose grandfathering. Confirm this is the intended behavior.
  • Only successRedirectUrl is gated — the "Redirect on no routing form response" toggle is NOT gated. Confirm this is the intended scope.
  • No automated tests for the API v2 guard logic (test file was removed due to module resolution issues in the jest environment).
  • Import reordering: The diff shows import statement reordering in event-types.service.ts — this is auto-formatter noise from biome, not intentional changes.

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 20, 2026
@PeerRich PeerRich marked this pull request as ready for review February 23, 2026 16:04
@PeerRich PeerRich requested a review from a team as a code owner February 23, 2026 16:04
@CarinaWolli CarinaWolli assigned CarinaWolli and unassigned PeerRich Feb 24, 2026
@CarinaWolli CarinaWolli marked this pull request as draft February 24, 2026 08:01
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 8 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/features/eventtypes/lib/successRedirectUrlAllowed.ts">

<violation number="1" location="packages/features/eventtypes/lib/successRedirectUrlAllowed.ts:33">
P2: Use a membership lookup that selects only the needed field (e.g., `id`) or a boolean-only helper to avoid fetching the full membership row when checking team plan eligibility.</violation>
</file>

<file name="packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts">

<violation number="1" location="packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts:847">
P1: The redirect URL plan check runs after the event type update, so the database already contains the new redirect URL. Since `checkSuccessRedirectUrlAllowed` allows updates when a redirect URL exists, this gate will always pass and free users can still set `successRedirectUrl`. Move the check before the update so unauthorized changes are blocked before persisting.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

@devin-ai-integration
Copy link
Contributor

Reviewed the Cubic AI feedback on this PR. Both issues have confidence scores below the 9/10 threshold for automated fixes:

  • Violation 1 (successRedirectUrlAllowed.ts:33 — P2 membership lookup optimization): Confidence 7/10 — Skipping.
  • Violation 2 (update.handler.ts:847 — redirect URL check ordering): Confidence 8/10 — Skipping.

No changes made as neither issue meets the 9/10 confidence threshold for automated fixes. These can be reviewed manually if needed.

Link to Devin run

Copy link
Member

@sean-brydon sean-brydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks pretty solid - Is this something we want to allow on team/org trials?

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/features/ee/teams/lib/checkUserHasActivePaidTeamPlan.ts">

<violation number="1" location="packages/features/ee/teams/lib/checkUserHasActivePaidTeamPlan.ts:49">
P2: Select only the plan field from platformBilling to avoid fetching unnecessary columns and potential sensitive data exposure.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@PeerRich PeerRich marked this pull request as ready for review February 28, 2026 20:22
@PeerRich PeerRich requested a review from a team as a code owner February 28, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants