fix: Support domains without @ prefix in watchlist#24476
Conversation
WalkthroughThe change standardizes domain normalization to use plain domain strings without a leading @. The normalization utility now strips any leading @ and returns the domain. Services and their tests (GlobalBlockingService, OrganizationBlockingService, WatchlistService) are updated to pass domains without @ to repository methods. The free email domain check was simplified to use emailDomain directly (no slice) and to pass the plain domain to isFreeEmailDomain. Bookings spam test data now constructs emails as user@${blockedDomain}. No exported/public signatures changed. Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (7)
🧰 Additional context used📓 Path-based instructions (3)**/*.ts📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Files:
**/*.{ts,tsx,js,jsx}⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (1)📚 Learning: 2025-08-27T13:32:46.887ZApplied to files:
🧬 Code graph analysis (2)packages/features/watchlist/lib/utils/normalization.test.ts (1)
packages/features/watchlist/lib/freeEmailDomainCheck/checkIfFreeEmailDomain.ts (1)
🔇 Additional comments (14)
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. |
44c7abe to
bd1aa42
Compare
alishaz-polymath
left a comment
There was a problem hiding this comment.
Legend! Thank you. 🫡
E2E results are ready! |

What does this PR do?
Fixes domain matching in the watchlist spam detection system. Domains stored in the database without the
@prefix (e.g.,qq.com) were not matching because thenormalizeDomain()function was adding an@prefix during lookups.Problem
The
normalizeDomain()function was returning domains with an@prefix (e.g.,@qq.com), but database records store domains WITHOUT the prefix (e.g.,qq.com). This mismatch caused domain-based spam blocking to fail completely.Example scenario:
qq.comuser@qq.com@qq.com@qq.comSolution
Removed the
@prefix from thenormalizeDomain()function return value to align with how domains are stored in the database.After fix:
qq.comuser@qq.comqq.comqq.comChanges Made
Core Logic
normalizeDomain()to return domain without@prefixTest Updates
Updated expectations in all test files to expect domains without
@prefix:Testing
✅ All tests passing:
How to test manually
Add a domain to the watchlist without
@prefix:Try to create a booking with email
user@testdomain.comExpected result: Booking should be blocked and return a decoy response
Impact
@prefix will now match properlyMandatory Tasks