feat: add option to skip CRM cancellation for blocklisted bookings#28492
feat: add option to skip CRM cancellation for blocklisted bookings#28492joeauyeung wants to merge 3 commits intomainfrom
Conversation
- Add blocklistSkipCrmOnCancel field to OrganizationSettings schema - Add UI toggle on the organization blocklist privacy page - Wire up setting through SpamCheckService and RegularBookingService - Add BlockingResult.skipCrmOnCancel flag for downstream consumers - Add i18n translation strings Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
There was a problem hiding this comment.
2 issues found across 11 files
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/bookings/lib/service/RegularBookingService.ts">
<violation number="1" location="packages/features/bookings/lib/service/RegularBookingService.ts:674">
P2: This adds an awaited organization settings query on every org booking attempt, even when the booking is not blocked. It creates avoidable latency/load in a hot path; defer this lookup until a blocked result actually needs the flag (or fetch it lazily inside spam-check handling).</violation>
</file>
<file name="apps/web/modules/ee/organizations/components/BlocklistSkipCrmOnCancelSwitch.tsx">
<violation number="1" location="apps/web/modules/ee/organizations/components/BlocklistSkipCrmOnCancelSwitch.tsx:17">
P2: The toggle uses optimistic local state but never rolls back or re-syncs from updated props after a failed mutation, so UI state can drift from the persisted organization setting.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| }); | ||
|
|
||
| spamCheckService.startCheck({ email: bookerEmail, organizationId: eventOrganizationId }); | ||
| const orgSettings = eventOrganizationId |
There was a problem hiding this comment.
P2: This adds an awaited organization settings query on every org booking attempt, even when the booking is not blocked. It creates avoidable latency/load in a hot path; defer this lookup until a blocked result actually needs the flag (or fetch it lazily inside spam-check handling).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/features/bookings/lib/service/RegularBookingService.ts, line 674:
<comment>This adds an awaited organization settings query on every org booking attempt, even when the booking is not blocked. It creates avoidable latency/load in a hot path; defer this lookup until a blocked result actually needs the flag (or fetch it lazily inside spam-check handling).</comment>
<file context>
@@ -671,7 +671,18 @@ async function handler(
});
- spamCheckService.startCheck({ email: bookerEmail, organizationId: eventOrganizationId });
+ const orgSettings = eventOrganizationId
+ ? await deps.prismaClient.organizationSettings.findUnique({
+ where: { organizationId: eventOrganizationId },
</file context>
apps/web/modules/ee/organizations/components/BlocklistSkipCrmOnCancelSwitch.tsx
Show resolved
Hide resolved
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. ✅ Pushed commit |
…celSwitch Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
What does this PR do?
Adds an organization-level setting
blocklistSkipCrmOnCancelthat, when enabled, signals that silently cancelled bookings from blocklisted emails/domains should skip the CRM cancellation flow.Changes:
blocklistSkipCrmOnCancelboolean field onOrganizationSettings(Prisma schema + migration)OrganizationRepository.findCurrentOrgexposes the fieldBlocklistSkipCrmOnCancelSwitchtoggle component on the org privacy/blocklist pageSpamCheckServiceaccepts and threads the flag through toBlockingResult.skipCrmOnCancelRegularBookingServicefetches the org setting and passes it tostartCheckSpamCheckServicecovering the newskipCrmOnCancelflag behaviorThe
BlockingResult.skipCrmOnCancelflag is plumbed through but no downstream code currently reads it to conditionally skip CRM operations. A follow-up change is needed in the booking cancellation/decoy path (e.g.,EventManagerorhandleCancelBooking) to actually honor this flag and skip CRM event deletion when it istrue. This PR establishes the setting, UI, and data flow — the behavioral change is not yet wired end-to-end.Items for reviewer attention
RegularBookingServicenow callsorganizationSettings.findUniquefor every org booking attempt, not just blocked ones. Consider whether this should be deferred until afterspamCheckResult.isBlockedis confirmed, or batched with existing org data fetching.hasOwnProperty→Object.hasOwnrefactor across all settings inupdate.handler.ts, import reordering (biome auto-fix), and a whitespace fix. These are cosmetic but inflate the diff.skipCrmOnCancelonly set for org-level blocks: Global blocks won't carry this flag — intentional since the setting lives onOrganizationSettings.Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
OrganizationSettings.blocklistSkipCrmOnCancelin the databaseNote: End-to-end behavioral verification (CRM events actually being skipped on blocked booking) requires downstream consumption code which is not yet implemented.
Checklist
Link to Devin session: https://app.devin.ai/sessions/28be88bf0b1d435993609f0ce3f9841a
Requested by: @joeauyeung