-
Notifications
You must be signed in to change notification settings - Fork 10.7k
feat: Add async spam check with parallel execution and fake booking redirect #24326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/spam-block-di
Are you sure you want to change the base?
feat: Add async spam check with parallel execution and fake booking redirect #24326
Conversation
…edirect - Create SpamCheckService to manage async spam checking - Start spam check early in handleNewBooking, await before booking creation - Generate fake booking response for blocked emails with all required fields - Add redirect logic in useBookings to handle spam decoy bookings - Create new /booking-successful route to display fake booking data - Spam check runs in parallel with availability loading (zero delay) - Spammers see convincing fake success page via query params Also fix pre-existing lint warnings in useBookings.ts: - Remove unused catch parameter - Convert optional chaining expressions to if statements - Remove eslint-disable comments for non-existent rule Stacked on PR #24040 Co-Authored-By: hariom@cal.com <hariombalhara@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:
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The latest updates on your projects. Learn more about Vercel for GitHub. |
- Import and load prismaModule in watchlist container for PrismaClient binding - Fix loggerServiceModule to use synchronous factory (matches prismaModule pattern) - Resolves 'logger.getSubLogger is not a function' error in tests - spam-booking.test.ts now passes successfully Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
…tual implementation Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
…g-successful page Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
…g-successful page Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
57db386
to
eb9900b
Compare
- Resolved merge conflict in watchlist.ts by keeping DI_TOKENS import (required for line 20) - Updated spam-check-flow.mermaid architecture notes to reflect base branch changes: - GlobalBlockingService now takes orgRepo instead of auditService - OrganizationBlockingService has optional audit logging Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Resolve merge conflict in watchlist.ts by keeping DI_TOKENS import - Add optional chaining to searchParams in booking-successful page - Add missing iCalUID, paymentId, and luckyUsers properties to fake booking response - Update CombinedBlockingService and OrganizationBlockingService per base branch changes (audit logging now only in CombinedBlockingService) - Prefix unused organizationId parameter with underscore per linting rules All type checks and linting passing with 0 errors. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
The remote branch refactored the spam check architecture: - Removed CombinedBlockingService.ts (logic moved to SpamCheckService) - SpamCheckService now directly uses GlobalBlockingService and OrganizationBlockingService - Added SpamCheckService.container.ts for DI setup - Enhanced spam-booking.test.ts with comprehensive test coverage - Improved OrganizationBlockingService with better email normalization This is a cleaner architecture that simplifies the service layer. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Updated OrganizationBlockingService to match base branch (removed audit logging) - Updated mappers.ts to match base branch (removed extra types and functions) - Fixed TypeScript errors caused by merge conflict resolution - All type checks now passing Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Removed reference to CombinedBlockingService (doesn't exist in base branch) - Updated to show SpamCheckService directly calling GlobalBlockingService and OrganizationBlockingService - Clarified parallel execution flow - Updated architecture notes to match actual implementation Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
89258f0
to
649e0c2
Compare
What does this PR do?
This PR implements an async spam blocker for Cal.com that runs spam checks in parallel with availability loading to achieve zero performance impact on legitimate bookings.
Key Features:
Stacked on: #24040 (feat: Add spam blocker DI structure)
Visual Demo
Manual testing completed for both spam and legitimate booking paths:
Spam Path Test:
spamtest@blocked.com
(added to Watchlist with BLOCK action)/booking-successful
pageLegitimate Path Test:
legitimate@user.com
(clean, not in watchlist)Architecture
New Components
SpamCheckService
: Orchestrates parallel global + org blocking checks/booking-successful
page: Fake success page that deceives spammersspamCheck.ts
for dependency injectionbooking_confirmed_description
,confirmation_email_sent
Key Flow Changes
spamCheckService.startCheck(email, orgId)
await spamCheckService.waitForCheck()
isSpamDecoy: true
flagHow should this be tested?
Prerequisites
Test Scenarios
Spam Detection Path:
action: BLOCK
/booking-successful
(not standard success page)Legitimate User Path:
Performance Testing:
Checklist
Risk Areas for Review
eventType.team?.parentId
pattern matches existing codebase conventions for organization ID extraction.waitForCheck()
call must complete before proceeding./booking-successful
page for proper sanitization of URL parameters to prevent XSS.CombinedBlockingService
- verify my implementation correctly uses separateGlobalBlockingService
andOrganizationBlockingService
.Mandatory Tasks
spam-booking.test.ts
passes without additional mocking)Requested by: @hariombalhara
Devin Session: https://app.devin.ai/sessions/8aaeeecf6dfc45ef90973a7e5249a2aa