feat: Add spam blocker DI structure#24040
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
WalkthroughReplaces legacy Watchlist repository API with a DI-based Watchlist feature façade and wiring (tokens, module, container). Adds typed DTOs, normalization and telemetry utilities, Global/Organization blocking services, WatchlistService and WatchlistAuditService, Prisma-backed repositories, and a free-email-domain check. Refactors controllers to accept structured params and optional spans, removes old repository/mocks, and adds/updates tests. Also introduces an ApiKeyService and updates verifyApiKey middleware to use it. Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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 |
packages/lib/di/watchlist/repositories/PrismaAuditRepository.ts
Outdated
Show resolved
Hide resolved
- Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
* feat: Add async spam check integration and decoy booking response - Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * Do checks in paralle * Fix leaking host name in title * Reduce expoiry time localstorage --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…g data (#24450) * feat: Add async spam check integration and decoy booking response - Integrate SpamCheckService with handleNewBooking workflow - Implement parallel spam check execution for minimal performance impact - Add decoy booking response with localStorage-based success page - Extract organization ID from event type for org-specific blocking - Add comprehensive test coverage for spam detection scenarios - Create reusable components for booking success cards - Implement fail-open behavior to never block legitimate bookings This builds on the spam blocker DI infrastructure from PR #24040 by adding the actual integration into the booking flow and implementing the decoy response mechanism to avoid revealing spam detection to malicious actors. Related: #24040 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * Do checks in paralle * Fix leaking host name in title * Reduce expoiry time localstorage * refactor: Use sessionStorage instead of localStorage for decoy booking data - Replace localStorage with sessionStorage for automatic expiration on tab close - Remove timestamp tracking and TTL logic (no longer needed) - Improve privacy by auto-clearing data when browser tab/window closes - Update documentation to reflect sessionStorage behavior This change addresses privacy concerns by ensuring decoy booking data (including attendee email) is automatically removed when the user closes the tab, rather than persisting for 5 minutes or requiring manual cleanup. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * feat: Add sessionStorage wrapper to webstorage module Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * Reset RegularBookingService.ts to main's version exactly * feat: Add 5-minute expiration timeout to decoy booking data - Adds timestamp to DecoyBookingData interface - Checks expiration when retrieving booking data - Automatically removes expired data from sessionStorage - Provides defense-in-depth against potential misuse - Works alongside sessionStorage auto-clear on tab close --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
What does this PR do?
Summary
This PR introduces a lean, testable Dependency Injection (DI) structure for the Watchlist/Spam-Blocker feature and applies it at the key edges (signup/admin/API/booking flows). This PR also updates the Watchlist schema for a more scalable and purposeful design. The goal is simple: keep data access in repositories, keep orchestration in controllers, and keep business logic in services—with a small façade as the entrypoint.
Highlights
What changed (high level)
Feature boundary
Added Watchlist DI surface: tokens, module, container, and a façade exposing:
globalBlocking.isBlocked(email)orgBlocking.isBlocked(email, orgId)Repositories only
tx.Services
Controllers / Edges
Telemetry
startSpanusage is normalized so span wrappers always return a Promise. Easier to stub/no-op in tests.Tests
/api/users), verifying real request → controller → service → repo flow.Behavior (intentionally simple)
Global Email Blocklist -> Global Domain Blocklist -> Org Email Blocklist -> Org Domain BlocklistHow to validate
getWatchlistFeature) to see the small surface and the precedence/failure-default JSDoc./api/users) to see real data flow and watchlist auto-lock behavior.Risks & mitigations
getSubLoggervschild): addressed via a small scoping/wrapper so services don’t break across logger backends.Reviewer checklist
@calcom/prisma(or@prisma/client) imports outside**/repository/**.Outcome: A pragmatic, DI-first foundation for spam blocking: simple today, clean seams for future policy/DTO growth, and reliable tests that exercise the real wiring.
Visual Demo (For contributors especially)
A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).
Video Demo (if applicable):
Image Demo (if applicable):
Mandatory Tasks (DO NOT REMOVE)
Checklist