Skip to content

Comments

fix: Add new route to create team routing-form response#22347

Merged
hariombalhara merged 5 commits intomainfrom
07-09-fix_add_formid_ownership_with_org_guard
Jul 10, 2025
Merged

fix: Add new route to create team routing-form response#22347
hariombalhara merged 5 commits intomainfrom
07-09-fix_add_formid_ownership_with_org_guard

Conversation

@hariombalhara
Copy link
Member

@hariombalhara hariombalhara commented Jul 9, 2025

What does this PR do?

Follow up to #22239

Organization Teams Routing Forms Response Endpoint

This PR adds a new teams routing forms endpoint that reuses existing routing form response logic by creating a shared service. The changes extract common functionality into a SharedRoutingFormResponseService and add a new teams-specific route while maintaining the existing organization-level endpoint.

Key Changes

Architecture

  • Created SharedRoutingFormResponseService to centralize routing form response logic
  • Implements shared service pattern for code reusability
  • Added a new Or composite guard to allow using multiple guards as OR

API Endpoints

  • Added new teams routing forms endpoint that reuses existing response creation logic
  • Maintained backward compatibility with existing organization endpoints
  • Updated API documentation to include the new teams endpoint

Security & Validation

  • Added IsUserRoutingForm guard for proper form ownership validation
  • Reuses existing routing form response logic for teams endpoint
  • Adds proper form ownership validation with organization guard

The implementation follows established patterns while extending functionality to support team-level routing forms without duplicating core logic.

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

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. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@vercel vercel bot temporarily deployed to Preview – api July 9, 2025 11:40 Inactive
@vercel
Copy link

vercel bot commented Jul 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2025 11:13am
cal-eu ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2025 11:13am

@vercel vercel bot temporarily deployed to Preview – cal July 9, 2025 11:40 Inactive
Copy link
Member Author

hariombalhara commented Jul 9, 2025

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Jul 9, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jul 9, 2025

No security or compliance issues detected. Reviewed everything up to a20e98b.

Security Overview
  • 🔎 Scanned files: 15 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@hariombalhara hariombalhara changed the base branch from response-record-fixes-quick-followup to graphite-base/22347 July 9, 2025 13:15
@hariombalhara hariombalhara changed the title fix: Add formId ownership with org guard fix: Add new route to create team routing-form responses Jul 9, 2025
@hariombalhara hariombalhara force-pushed the graphite-base/22347 branch from 48759fa to 6410687 Compare July 9, 2025 13:15
@hariombalhara hariombalhara force-pushed the 07-09-fix_add_formid_ownership_with_org_guard branch from 76e905f to 4718b8b Compare July 9, 2025 13:15
@hariombalhara hariombalhara changed the title fix: Add new route to create team routing-form responses fix: Add new route to create team routing-form response Jul 9, 2025
@hariombalhara hariombalhara changed the base branch from graphite-base/22347 to main July 9, 2025 13:15
@hariombalhara hariombalhara force-pushed the 07-09-fix_add_formid_ownership_with_org_guard branch from 4718b8b to 505d6e4 Compare July 9, 2025 13:19
Comment on lines -85 to 86
const result = await this.organizationsRoutingFormsResponsesService.createRoutingFormResponseWithSlots(
orgId,
routingFormId,
Copy link
Member Author

Choose a reason for hiding this comment

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

Was unused

Comment on lines -90 to -132
}

// Extract event type information from the routed URL
const { eventTypeId, crmParams } = await this.extractEventTypeAndCrmParams(redirectUrl);

const paramsForGetAvailableSlots = {
type: ById_2024_09_04_type,
eventTypeId,
...slotsQuery,
...crmParams,
} as const;

// Get available slots using the slots service with CRM parameters
const slots = await this.slotsService.getAvailableSlots(paramsForGetAvailableSlots);
const teamMemberIds = crmParams.routedTeamMemberIds ?? [];
const teamMemberEmail = crmParams.teamMemberEmail ?? undefined;
const skipContactOwner = crmParams.skipContactOwner ?? undefined;
const queuedResponseId = crmParams.queuedFormResponseId ?? null;
const responseId = crmParams.routingFormResponseId ?? null;
const crmAppSlug = crmParams.crmAppSlug ?? undefined;
const crmOwnerRecordType = crmParams.crmOwnerRecordType ?? undefined;

if (responseId) {
return {
routing: {
responseId,
teamMemberEmail,
teamMemberIds,
skipContactOwner,
crmAppSlug,
crmOwnerRecordType,
},
eventTypeId,
slots,
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved all this to shared service

@Req() request: Request
): Promise<CreateRoutingFormResponseOutput> {
const result = await this.organizationsRoutingFormsResponsesService.createRoutingFormResponseWithSlots(
orgId,
Copy link
Member Author

Choose a reason for hiding this comment

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

Was unused

@hariombalhara hariombalhara marked this pull request as ready for review July 9, 2025 13:29
@hariombalhara hariombalhara requested a review from a team July 9, 2025 13:29
@hariombalhara hariombalhara requested a review from a team as a code owner July 9, 2025 13:29
@graphite-app graphite-app bot requested a review from a team July 9, 2025 13:30
@dosubot dosubot bot added api area: API, enterprise API, access token, OAuth routing-forms area: routing forms, routing, forms labels Jul 9, 2025
@graphite-app
Copy link

graphite-app bot commented Jul 9, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (07/09/25)

1 reviewer was added to this PR based on Keith Williams's automation.

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.

cubic found 2 issues across 12 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@vercel vercel bot temporarily deployed to Preview – api July 10, 2025 09:25 Inactive
@dosubot dosubot bot added teams area: teams, round robin, collective, managed event-types ✨ feature New feature or request labels Jul 10, 2025
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.

cubic found 4 issues across 15 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 10, 2025

E2E results are ready!

Copy link
Contributor

@supalarry supalarry left a comment

Choose a reason for hiding this comment

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

Love the new shared service and tests, but have some comments below:

@hariombalhara hariombalhara force-pushed the 07-09-fix_add_formid_ownership_with_org_guard branch from 9ac891f to a20e98b Compare July 10, 2025 11:13
@supalarry supalarry requested a review from ThyMinimalDev July 10, 2025 11:21
@hariombalhara hariombalhara enabled auto-merge (squash) July 10, 2025 11:36
@hariombalhara hariombalhara merged commit 89e7fca into main Jul 10, 2025
90 of 95 checks passed
@hariombalhara hariombalhara deleted the 07-09-fix_add_formid_ownership_with_org_guard branch July 10, 2025 11:56
keithwillcode added a commit that referenced this pull request Jul 10, 2025
keithwillcode added a commit that referenced this pull request Jul 11, 2025
Arephan pushed a commit to Arephan/cal.com that referenced this pull request Jul 11, 2025
* fix: Add formId ownership with org guard

* Don't allow user routing form endpoint to create response for team
routing form

* rename to or guard
Arephan pushed a commit to Arephan/cal.com that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 11, 2025
hariombalhara added a commit that referenced this pull request Jul 17, 2025
…evert earlier) (#22407)

* Revert "revert: "fix: Add new route to create team routing-form response (#22347)" (#22399)"

This reverts commit e6c36af.

* Update the documentation

* Remove versioning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api area: API, enterprise API, access token, OAuth core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request ready-for-e2e routing-forms area: routing forms, routing, forms teams area: teams, round robin, collective, managed event-types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants